borgkling2003
MIS
I am builidng a web form in asp.net.
Theres one registration page and one thankyou page. When user submit a postback will occur. I have trouble capturing the data. Could someone please have a look at the script and tell me how to solve it? thanks.
Heres my script:
if (IsPostBack)
{
SqlConnection myDOTNET = new SqlConnection();
myDOTNET.ConnectionString = "data source=10.0.0.1;initial catalog=test;user id=ass;password=;";
myDOTNET.Open();
DataSet custDS = new DataSet("DOTNET_TEST");
DataRow anyRow = custDS.Tables["DOTNET_TEST"].NewRow();
anyRow["FNAME"] = "Jay";
custDS.Tables["DOTNET_TEST"].Rows.Add(anyRow);
myDOTNET.Close();
Response.Redirect("Thankyou.aspx");
}
After submitting the following error is shown.
error occurs here:
DataRow anyRow = custDS.Tables["DOTNET_TEST"].NewRow();
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object
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.
Theres one registration page and one thankyou page. When user submit a postback will occur. I have trouble capturing the data. Could someone please have a look at the script and tell me how to solve it? thanks.
Heres my script:
if (IsPostBack)
{
SqlConnection myDOTNET = new SqlConnection();
myDOTNET.ConnectionString = "data source=10.0.0.1;initial catalog=test;user id=ass;password=;";
myDOTNET.Open();
DataSet custDS = new DataSet("DOTNET_TEST");
DataRow anyRow = custDS.Tables["DOTNET_TEST"].NewRow();
anyRow["FNAME"] = "Jay";
custDS.Tables["DOTNET_TEST"].Rows.Add(anyRow);
myDOTNET.Close();
Response.Redirect("Thankyou.aspx");
}
After submitting the following error is shown.
error occurs here:
DataRow anyRow = custDS.Tables["DOTNET_TEST"].NewRow();
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object
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.