Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
Try
Dim cmd As New OleDbCommand
cmd.Connection = conn
cmd.CommandText = "INSERT INTO Credit(Credit_ID, Member_ID, Crebit, Total, Date, Remark) VALUES ('" & txtCreID.Text & "','" & txtMemberID.Text & "','" & txtCredit.Text & "','" & txtTotal.Text & "','" & DateTimePicker1.Text & "','" & txtRemark.Text & "')"
With cmd
cmd.ExecuteNonQuery()
conn.Close()
End With
MsgBox("บันทึกข้อมูลเรียบร้อยแล้วค่ะ", vbOKOnly, "Save Data")
Dim cn As New System.Data.OleDb.OleDbConnection(connstring)
Dim da As New System.Data.OleDb.OleDbDataAdapter
Dim ds As New DataSet
Dim sql1 As String = "select * from Credit"
da.SelectCommand = New System.Data.OleDb.OleDbCommand(sql1, cn)
da.Fill(ds, "Credit")
DataGridView1.DataSource = ds.Tables("Credit")
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
Try
Dim cmd As New OleDbCommand
cmd.Connection = conn
cmd.CommandText = "INSERT INTO Credit(Credit_ID, Member_ID, Crebit, Total, `Date`, Remark) VALUES ('" & txtCreID.Text & "','" & txtMemberID.Text & "','" & txtCredit.Text & "','" & txtTotal.Text & "','" & _ DateTimePicker1.Values.ToString("yyyy/MM/dd") & "','" & txtRemark.Text & "')"
With cmd
cmd.ExecuteNonQuery()
conn.Close()
End With
MsgBox("บันทึกข้อมูลเรียบร้อยแล้วค่ะ", vbOKOnly, "Save Data")
Dim cn As New System.Data.OleDb.OleDbConnection(connstring)
Dim da As New System.Data.OleDb.OleDbDataAdapter
Dim ds As New DataSet
Dim sql1 As String = "select * from Credit"
da.SelectCommand = New System.Data.OleDb.OleDbCommand(sql1, cn)
da.Fill(ds, "Credit")
DataGridView1.DataSource = ds.Tables("Credit")
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub