hey everyone im sort off new on .net and i was wondering if u can help me bigtime.. i am having problems with editing records when i do a search. example i was to search a specific record but then when i try to edit it, it turned out that i am editing the wrong record. but i can update records if i didnt search it.
here is my code for searching:
Private Sub search()
Dim str As String
str = "select * from user_t where Username like ('" & Trim(txtSearch.Text) & "%')"
Try
con.Open()
Dim com1 As New SqlClient.SqlCommand(str, con)
Dim dr As SqlClient.SqlDataReader = com1.ExecuteReader
While dr.Read
txtUsername.Text = "" & (dr.GetValue(0))
txtPassword.Text = "" & (dr.GetValue(1))
cbUsertype.Text = "" & (dr.GetValue(2))
End While
If Not dr.HasRows Then
MsgBox("No records found. Please try again.", MessageBoxIcon.Error, "No records found")
txtSearch.Clear()
End If
con.Close()
Catch ex As Exception
con.Close()
End Try
End Sub
and for updating:
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(da)
ds.Tables("user_t").Rows(inc).Item("Username") = txtUsername.Text
ds.Tables("user_t").Rows(inc).Item("Password") = txtPassword.Text
MsgBox("User Updated", MsgBoxStyle.Information, "Update Successful")
da.Update(ds, "user_t")
i really need ur help guys..hehe