hi
am trying to save records to table can any one tel me what exactly problem with my code
my system date time format
dd-MM-yyyy
sql tbl_agreement1
ID int Unchecked
Party1 nvarchar(50) Checked
Party1ADD nvarchar(50) Checked
Party2 nvarchar(50) Checked
Party2add nvarchar(50)
Capacity nvarchar(50)
Agper nvarchar(50)
AGtop nvarchar(50)
AGplace nvarchar(50)
Tnco nvarchar(50)
Status nvarchar(50)
Endno nvarchar(50)
Mulahiq varchar(50)
Qarar nvarchar(50)
entered nvarchar(MAX)
username nvarchar(MAX)
[update] nvarchar(MAX)
[last update date] datetime2(0)
laspusername nvarchar(MAX)
[entered-date] datetime2(0)
AGend datetime
AGdt datetime
Enddt datetime
//button click
protected void Button2_Click(object sender, EventArgs e)
{
string dt = DateTime.Now.ToShortDateString();
try
{
DAL.InsertAgreement3(TextBox1.Text, TextBox2.Text,TextBox3.Text,TextBox4.Text,TextBox5.Text,TextBox6.Text,TextBox7.Text,TextBox8.Text,TextBox9.Text,TextBox10.Text,TextBox12.Text,TextBox11.Text,TextBox13.Text,TextBox14.Text,TextBox15.Text,TextBox16.Text, Session["username"].ToString());
info.Style.Add("display", "block");
lblerror.Visible = true;
lblerror.Text = "Successfuly Inserted Record...";
Response.Redirect("Agreement3.aspx");
}
catch (Exception ex)
{
info.Style.Add("display", "block");
lblerror.Visible = true;
lblerror.Text = "Error Occured while adding.....!!!!! " + " " + ex.Message;
}
}
<pre>
public static void InsertAgreement3(string Agdt, string party1, string partyadd, string party2, string party2add, string capacity, string agper, string agtop, string agplace, string Termscon, string Agend, string Status, string EndNo, string Enddate, string Mulahiq, string Qarar, string uname)
{
DateTime dt;
string sdt = System.DateTime.Now.ToString();
string sdt1 = DateTime.Now.ToShortDateString();
SqlConnection sqlconn = new SqlConnection(ConnString);
try
{
sqlconn.Open();
string Query = "INSERT INTO [tbl_agreement1]([AGdt],[Party1],[Party1ADD],[Party2],[Party2ADD],[Capacity],[AGper],[AGtop],[AGPlace],[Tnco],[AGend],[Status],[Endno],[Enddt],[Mulahiq],[Qarar],[entered],[entered-date],[username]) VALUES (N'" + DateTime.Parse(Agdt).ToString(new CultureInfo("en-US")) + "',N'" + party1 + "',N'" + partyadd + "',N'" + party2 + "',N'" + party2add + "',N'" + capacity + "',N'" + agper + "',N'" + agtop + "',N'" + agplace + "',N'" + Termscon + "',N'" + DateTime.Parse(Agend).ToString(new CultureInfo("en-US")) + "',N'" + Status + "',N'" + EndNo + "',N'" + DateTime.Parse(Enddate).ToString(new CultureInfo("en-US")) + "',N'" + Mulahiq + "',N'" + Qarar + "',N'" + "New Record Added" + "',N'" + DateTime.Parse(sdt).ToString(new CultureInfo("en-US")) + "',N'" + uname + "' )";
SqlCommand sqlcomm = new SqlCommand(Query, sqlconn);
sqlcomm.ExecuteNonQuery();
}
catch (Exception ex)
{
}
finally
{
sqlconn.Close();
}
can any one suggest me for this m not able to save records...
thank you...