รายละเอียดของการตอบ ::
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, DateCR, Remark) VALUES ('" & txtCreID.Text & "','" & txtMemberID.Text & "','" & txtCredit.Text & "','" & txtTotal.Text & "','" & DateTimePicker1.Value.ToString("yyyy/MM/dd") & "','" & txtRemark.Text & "')"
With cmd
cmd.ExecuteNonQuery()
conn.Close()
End With
MsgBox("บันทึกข้อมูลเรียบร้อยแล้วค่ะ", vbOKOnly, "Save Data")
'***********************************************************************************************
Dim sqlADD As String
sqlADD = "UPDATE MemberID SET Total='" & Trim(txtTotal.Text) & "' WHERE Member_ID=" & Trim(txtMemberID.Text) & " "
Dim sqlcommand As New OleDbCommand
With sqlcommand
.CommandText = sqlADD
.Connection = conn
.ExecuteNonQuery()
End With
MsgBox("การแก้ไขข้อมูลของคุณเรียบร้อยแล้ว", vbOKOnly, "Edit Data")
txtMemberID.Text = ""
txtTitleN.Text = ""
txtName.Text = ""
txtLast.Text = ""
'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
แบบนี้หรอคะ