Problem updating to databse from textbox.

tiffany

Well-known member
Joined
Aug 7, 2005
Messages
57
Programming Experience
1-3
Hi, I'm having a problem on updating the value to database from textbox. Initally, there is a textbox for display the retrieve valur from database. This textbox can be edit and update to the database. However, when this textbox has something retrieve and display it can't update to database. If this textbox didn't not retrieve anything from database and just do a update method it is susscessful.

this is my codes, can anyone help me to look at it? thank.

'this is the data layer page.
Public Function updateReply(ByVal strmsg As String, ByVal strname As String, ByVal strtopic As String, ByVal strSubcat As String, ByVal msID As Integer, ByVal uID As String, ByVal tID As Integer, ByVal dt As DateTime) As DataSet
Dim ds As New DataSet
Dim da As New SqlDataAdapter("UPDATE msg SET msg = '" + "%" + strmsg + "%" + "' WHERE topic = '" & strtopic & "'AND subCat = '" & strSubcat & "' AND msgID = '" & msID & "' AND userID = '" & uID & "'AND topicID LIKE '" & tID & "'AND datTim = '" & dt & "'", cn)
cn.Open()
da.Fill(ds)
cn.Close()
Return ds
End Function



'this is the presentation page
Dim strmsg As String = tb_msg.Text
Dim strname As String = lb_name.Text
Dim strtopic As String = lb_topic.Text
Dim strSubcat As String = lk_subCat.Text
Dim mID As Integer
Dim usID As String
Dim tID As Integer
Dim msdt As DateTime

mID = Session("msgID")
usID = Session("usID")
tID = Session("toID")
msdt = Session("md")


ds = bl.updateReply(strmsg, strname, strtopic, strSubcat, mID, usID, tID, msdt)



thankx. tiffany
 

vis781

Well-known member
Joined
Aug 30, 2005
Messages
2,015
Location
Cambridge, UK
Programming Experience
5-10
I have to day i am confused as to what yuo are trying to accomplish here.....
You have an UPDATE query but are calling the fill method of the sqldataadapter. If you want to fill the datatable then you need a SELECT command and the fill method. If you want to send changes back to the database then you need an action query i.e UPDATE, INSERT, DELETE then call the update method of the dataadapter. Also i would suggest that string concatenation is not a preferable way to construct queries, my advise would be to check out parameters.
 
Top Bottom