Update SQL Database with VB.Net

  • Thread starter Thread starter Prabaharan pichaiyan
  • Start date Start date
P

Prabaharan pichaiyan

Guest
I'm trying to update a single selected record in Data grid. But its update all the record with same value.

may I know what's wrong with my codes?

Private Sub updatesearchresBtn_Click(sender As Object, e As EventArgs) Handles updatesearchresBtn.Click

Try

MysqlConnection = New MySqlConnection(StrCon)
MysqlConnection.Open()
Dim str As String = "Update tb_userinfo.asset_data set id=@New_id,product=@New_product,entitlement_end_date=@New_eed"

Cmd = New MySqlCommand(str, MysqlConnection)

With Cmd.Parameters
.AddWithValue("@New_id", txtSRid.Text)
.AddWithValue("@New_product", txtSRproduct.Text)
.AddWithValue("@New_eed", txtSREedate.Text.ToString)

End With


Cmd.ExecuteNonQuery()

loadData()
Cmd.Dispose()
MysqlConnection.Close()

Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub


Thanks a lot

Continue reading...
 
Back
Top