I have currently two forms in mine website..I m also posting their codes--
FrmRegistration.aspx
public partial class FrmRegistration : System.Web.UI.Page
{
SqlConnection conn = new SqlConnection("Data Source=SONIA-B408A4159\\SQLEXPRESS;Initial catalog=sonia;Integrated Security=true");
string query;
SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
btnSubmit.Attributes.Add("onclick", "Javascript: return Validations() ");
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
query = "Insert into UserInfo values(@name,@email)";
cmd = new SqlCommand(query, conn);
conn.Open();
cmd.Parameters.AddWithValue("@name", txtName.Text);
cmd.Parameters.AddWithValue("@email", txtEmail.Text);
cmd.ExecuteNonQuery();
conn.Close();
Session["Name"] = txtName.Text;
Response.Redirect("FrmUserDetails.aspx");
}
}
FRMUSERDERATILS-
public partial class FrmUserDetails : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblUserName.Text = "SONIA";
//lblUserName.Text = Session["Name"].ToString ();
}
}
I publish the website using the foll. steps -
1. go to your root directory (in which your IIS is installed....assuming that you are using winxp sp2 and if you installed ur OS in "C" drive then usually your IIS's root folder does exist in -->"C:\Inetpub\WWWRoot")
2. Create a new folder there with any name you wish...e.g. TESTSITE for an example
3. Come back to VS2005 IDE....open your website
4. Goto "Build" menu and select "Publish Website" option.
5. Now click on ellipse(...) button and click to select "Local IIS" from the left panel of the dialog box that appears
6. Expand the "Default Web Site" node...there you can see the folder("TESTSITE") that you just created...Select the folder and click Open (if you see any message click on YES to proceed)
7. Make sure that the option "Allow this precompiled site to be updateable" is checked
8. Now click OK....publishment of your site will begin...notice the process in the outout window
9. If all goes well then you will see a message "Publish succeeded"....this means that you have successfully passed the hardle from VS2005
I type - http://localhost/testsite/FrmRegistration.aspx
Form is successfully opened ...
Suppose I enter sonia in txt name & [email address] in txtEmail & when i press submit - Error is dere.
Server Error in '/TESTSITE' Application.
--------------------------------------------------------------------------------
Cannot open database "sonia" requested by the login. The login failed.
Login failed for user 'SONIA-B408A4159\ASPNET'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Cannot open database "sonia" requested by the login. The login failed.
Login failed for user 'SONIA-B408A4159\ASPNET'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
When i run my website.by pressing F5,everything is working fine,Can somebody tell me y the error is dere??