Error in updating date
-
I have the following function writen in asp.net with vb script. when click the update button everthing is getting updated except "date" I tried to update using date.parse also but no use. The same code was woking fine previous say a week back. I have not made any changes also. But I am not finding any reasons for this. this is happening whereever i have used date. Insertion or updation of date and searching based on date is not working. Function update() Dim flag As Boolean flag = False Dim tran As SqlClient.SqlTransaction Dim a As String a = txtexpdate.text Dim d As Date = Date.parse(a) If txtremark.Text.Trim = "" Or lblcustname.Text.Trim = "" Or txtcustdrno.Text.Trim = "" Or txtbore.Text.Trim = "" Or txtstroke.Text.Trim = "" Or txtapplication.Text.Trim = "" Or txtrod.Text.Trim = "" Or txtpress.Text.Trim = "" Or txteqpmodel.Text.Trim = "" Then lblstatus.Visible = True lblstatus.ForeColor = Color.Red lblstatus.Text = "Fields can not be left blank !" Exit Function ElseIf IsNumeric(txtbore.Text.Trim) = False Or IsNumeric(txtstroke.Text.Trim) = False Or IsNumeric(txtrod.Text.Trim) = False Or IsNumeric(txtpress.Text.Trim) = False Then lblstatus.Visible = True lblstatus.ForeColor = Color.Red lblstatus.Text = "Bore,stroke,rod and working pressure should have numeric value !" Exit Function Else If dbconn.State <> ConnectionState.Open Then dbconn.Open() End If Dim comm As New SqlCommand() comm = dbconn.CreateCommand tran = dbconn.BeginTransaction comm.Transaction = tran Try comm.CommandText = "update D_proposal set cust_drw_no='" & txtcustdrno.Text.Trim & "',cust_name='" & lblcustname.Text.Trim & "',typ_cyl='" & txttypcyl.Text.Trim & "',cushioning='" & txtcush.Text.Trim & "',bore='" & txtbore.Text.Trim & "',stroke='" & txtstroke.Text.Trim & "',application='" & txtapplication.Text.Trim & "',category='" & txtcat.Text.Trim & "',sada='" & txtsada.Text.Trim & "',rod='" & txtrod.Text.Trim & "',wrk_press='" & txtpress.Text.Trim & "',eqp_mdl='" & txteqpmodel.Text.Trim & "',mounting='" & txtmounting.Text.Trim & "'where pno='" & lblpno.Text.Trim & "'" comm.ExecuteNonQuery() 'comm.CommandText = "update D_task_det set associate='" & txtassociate.Text.Trim
-
I have the following function writen in asp.net with vb script. when click the update button everthing is getting updated except "date" I tried to update using date.parse also but no use. The same code was woking fine previous say a week back. I have not made any changes also. But I am not finding any reasons for this. this is happening whereever i have used date. Insertion or updation of date and searching based on date is not working. Function update() Dim flag As Boolean flag = False Dim tran As SqlClient.SqlTransaction Dim a As String a = txtexpdate.text Dim d As Date = Date.parse(a) If txtremark.Text.Trim = "" Or lblcustname.Text.Trim = "" Or txtcustdrno.Text.Trim = "" Or txtbore.Text.Trim = "" Or txtstroke.Text.Trim = "" Or txtapplication.Text.Trim = "" Or txtrod.Text.Trim = "" Or txtpress.Text.Trim = "" Or txteqpmodel.Text.Trim = "" Then lblstatus.Visible = True lblstatus.ForeColor = Color.Red lblstatus.Text = "Fields can not be left blank !" Exit Function ElseIf IsNumeric(txtbore.Text.Trim) = False Or IsNumeric(txtstroke.Text.Trim) = False Or IsNumeric(txtrod.Text.Trim) = False Or IsNumeric(txtpress.Text.Trim) = False Then lblstatus.Visible = True lblstatus.ForeColor = Color.Red lblstatus.Text = "Bore,stroke,rod and working pressure should have numeric value !" Exit Function Else If dbconn.State <> ConnectionState.Open Then dbconn.Open() End If Dim comm As New SqlCommand() comm = dbconn.CreateCommand tran = dbconn.BeginTransaction comm.Transaction = tran Try comm.CommandText = "update D_proposal set cust_drw_no='" & txtcustdrno.Text.Trim & "',cust_name='" & lblcustname.Text.Trim & "',typ_cyl='" & txttypcyl.Text.Trim & "',cushioning='" & txtcush.Text.Trim & "',bore='" & txtbore.Text.Trim & "',stroke='" & txtstroke.Text.Trim & "',application='" & txtapplication.Text.Trim & "',category='" & txtcat.Text.Trim & "',sada='" & txtsada.Text.Trim & "',rod='" & txtrod.Text.Trim & "',wrk_press='" & txtpress.Text.Trim & "',eqp_mdl='" & txteqpmodel.Text.Trim & "',mounting='" & txtmounting.Text.Trim & "'where pno='" & lblpno.Text.Trim & "'" comm.ExecuteNonQuery() 'comm.CommandText = "update D_task_det set associate='" & txtassociate.Text.Trim
What is your date column datatype in Database ? Have you tried running the same query in query analyzer ? If so what error you got ?
-
What is your date column datatype in Database ? Have you tried running the same query in query analyzer ? If so what error you got ?
Now it is working. I have changed the enableviewstate property of all the controls to true and readonly property of datetextbox(text boxes where we have date value) to false. But i want datextbox readonly. What can I do for this?
Chaitra N