sb.Remove(0, sb.Length)
sb.Append("update cs")
sb.Append(" set name=@textbox2,IDcard=@textbox3,address=@textbox4,age=@textbox5,tel=@textbox6 ")
sb.Append(" where ('id_cus=@id_cus')")
Dim sqledit As String
sqledit = sb.ToString
With com
.CommandText = sqledit
.CommandType = CommandType.Text
.Connection = Conn
.Transaction = tr
.Parameters.Clear()
.Parameters.Add("@textbox2", OleDbType.VarChar).Value = TextBox2.Text.Trim
.Parameters.Add("@textbox3", OleDbType.VarChar).Value = TextBox3.Text.Trim
.Parameters.Add("@textbox4", OleDbType.VarChar).Value = TextBox4.Text.Trim
.Parameters.Add("@textbox5", OleDbType.VarChar).Value = TextBox5.Text.Trim
.Parameters.Add("@textbox6", OleDbType.VarChar).Value = TextBox6.Text.Trim
Dim result As Integer
result = .ExecuteNonQuery
If result = 0 Then
tr.Rollback()
TextBox1.SelectAll()
Else
tr.Commit()
MessageBox.Show("แก้ไขข้อมูลลูกค้าเรียบร้อยแล้ว!!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
showdata()
formatdgvcustomerlist()
End If
End With
Tag : .NET, Ms Access, Win (Windows App), VS 2008 (.NET 3.x)