Dim tr As OleDbTransaction
Dim sb As New StringBuilder
Dim com As OleDbCommand
'Dim success As Integer = CInt(True)
tr = Conn.BeginTransaction()
Try
sb.Remove(0, sb.Length)
sb.Append("INSERT INTO VisaSaleCard (Company_ID)")
sb.Append("VALUES (@Company_ID)")
Dim sqlAdd As String
sqlAdd = sb.ToString
With com
.CommandText = sqlAdd
.CommandType = CommandType.Text
.Connection = Conn
.Transaction = tr
.Parameters.Add("@Company_ID", OleDbType.Integer).Value = cbCustomer.Text.Trim
.ExecuteNonQuery()
End With
tr.Commit()
MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว", "ผลการทำงาน", MessageBoxButtons.OK)
Catch ex As Exception
tr.Rollback()
End Try
tbxNo.Focus()
End Sub
'ดึงข้อมูลมาใส่ combobox Customer
Dim sqlCompany As String
Dim bs As New BindingSource
sqlCompany = "SELECT * FROM Clients"
da = New OleDbDataAdapter(sqlCompany, Conn)
da.Fill(ds, "Clients")
bs.DataSource = ds
bs.DataMember = "Clients"
With cbCustomer
.DataSource = bs
.DisplayMember = "CompanyName"
.BeginUpdate()
.ValueMember = "CompanyID"
.EndUpdate()
End With