Hi There,
I have an application in ASP.net. It is an application where users enter their required information, then it saves to our SQL database. I am having some issues when the user is done entering their info and clicks the "submit" button, which is then saved to the database. The Confirmation_ID properties are: int; required; unique constraint enforced and is system generated.
Here is a snip of the method.
I have this piece of code below commented because it issues an error when we try to save the information.
It seems to save a record when I manually enters the confirmation_id number.
Does anyone have an idea why this is occurring? Any help/suggestions is very much appreciated!
I have an application in ASP.net. It is an application where users enter their required information, then it saves to our SQL database. I am having some issues when the user is done entering their info and clicks the "submit" button, which is then saved to the database. The Confirmation_ID properties are: int; required; unique constraint enforced and is system generated.
Here is a snip of the method.
Code:
private void saveRecord()
{
DataTable dtDataForm1=new DataTable();
DataTable dtDataForm2=new DataTable();
if (Session["sesEntry1"] != null && Session["sesEntry2"] != null)
{
dtDataForm1 = (DataTable)Session["Entry1"];
dtDataForm2 = (DataTable)Session["Entry2"];
DataSet RTables = new DataSet();
DataTable dt1 = new DataTable();
dt1.TableName = "Report_Header";
//DataColumn conf_Id = new DataColumn("Confirmation_ID", typeof(int));
//conf_Id.AutoIncrement = true;
//conf_Id.AutoIncrementSeed = 4;
//dt1.Columns.Add(conf_Id);
dt1.Columns.Add("Confirmation_ID", typeof(int));
dt1.Columns.Add("FirstName", typeof(int));
dt1.Columns.Add("LastName", typeof(int));
dt1.Columns.Add("MiddleName", typeof(string));
dt1.Columns.Add("Month", typeof(int));
dt1.Columns.Add("Year", typeof(int));
dt1.Columns.Add("Create_User", typeof(string));
dt1.Columns.Add("Create_Date", typeof(string));
dt1.Columns.Add("Modify_User", typeof(string));
dt1.Columns.Add("Modify_Date", typeof(string));
if (dtDataForm1.Rows.Count > 0)
{
DataRow r1 = dt1.NewRow();
r1["Confirmation_ID"] = 7;
r1["FirstName"] = Convert.ToInt32(dtDataForm1.Rows[0]["Clerk_ID"]);
r1["LastName"] = Convert.ToInt32(dtDataForm1.Rows[0]["checkBookID"]);
r1["MiddleName"] = dtDataForm1.Rows[0]["County"].ToString();
r1["Month"] = Convert.ToInt32(dtDataForm1.Rows[0]["month"]);
r1["Year"] = Convert.ToInt32(dtDataForm1.Rows[0]["year"]);
r1["Create_User"] = "test()";
r1["Create_Date"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
r1["Modify_User"] = "";
r1["Modify_Date"] = "";
dt1.Rows.Add(r1);
}
I have this piece of code below commented because it issues an error when we try to save the information.
Code:
//DataColumn conf_Id = new DataColumn("Confirmation_ID", typeof(int));
//conf_Id.AutoIncrement = true;
//conf_Id.AutoIncrementSeed = 1;
//dt1.Columns.Add(conf_Id);
It seems to save a record when I manually enters the confirmation_id number.
Code:
dt1.Columns.Add("Confirmation_ID", typeof(int));
Code:
r1["Confirmation_ID"] = 7;
Does anyone have an idea why this is occurring? Any help/suggestions is very much appreciated!