i am using visual web developer 2005 and SQL Express 2005 and VB as the code behind
i am using the following statement to update details in the database.it doesn't work
Protected Sub processbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles processbutton.Click
Dim update As New SqlDataSource()
update.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString").ToString()
update.UpdateCommandType = SqlDataSourceCommandType.Text
update.UpdateCommand = "UPDATE orderdetail SET fromdesignstatus = 11 , fromdesignlink = " + TextBox1.Text.ToString() +
"WHERE order_id =" + ordersid.ToString()
update.Update()
End Sub
the value of TextBox1 is obtained like this
Protected Sub uploadbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uploadbutton.Click
If FileUpload1.HasFile Then
FileUpload1.SaveAs("G:\project\My Project\OTS\ots\design\uploads\" + FileUpload1.FileName)
HyperLink1.Text = FileUpload1.FileName
HyperLink1.NavigateUrl = "uploads\" + FileUpload1.FileName
TextBox1.Text = FileUpload1.FileName
End If
End Sub
my ultimate aim is to upload the file and store the path in the database
what is wrong in my code ?
please help me
try this remember to put single quotes around text values and to have space between value and where clause (add extra space at the begin of every string you add when you build your query). I inserted quotes in red around your fromdesignlink field and I put space after it before where clause:
Protected Sub processbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles processbutton.Click
Dim update As New SqlDataSource()
update.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString").ToString()
update.UpdateCommandType = SqlDataSourceCommandType.Text
update.UpdateCommand = "UPDATE orderdetail SET fromdesignstatus = 11 , fromdesignlink ='" + TextBox1.Text.ToString() +
"' WHERE order_id =" + ordersid.ToString()
update.Update()
End Sub
No comments:
Post a Comment