Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'TelbookDataSet.Table1' table. You can move, or remove it, as needed.
Me.Table1TableAdapter.Fill(Me.TelbookDataSet.Table1)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Table1BindingSource.AddNew()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Table1BindingSource.RemoveCurrent()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Table1BindingSource.EndEdit()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Table1TableAdapter.Update(TelbookDataSet.Table1)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Table1BindingSource.MovePrevious()
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Table1BindingSource.MoveNext()
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Me.Close()
End Sub
End Class
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
me.Validate()
Table1BindingSource.EndEdit()'ชื่ออะไรก็ว่ากันไป
Table1TableAdapter.UpdateAll(this.DataSet)'ชื่ออะไรก็ว่ากันไป
End Sub
ปล.ทั้งนี้ ก็ต้อง ทำ Binding ใน TextBox หรือ control ต่างๆด้วยนะครับถึงจะใช้ตามที่บอกได้ผล
คำตอบแบบบ้านๆก็น่าจะประมาณนั้นแหละครับ
Date :
2016-10-30 11:09:37
By :
lamaka.tor
No. 10
Guest
Code
Imports System.Data.SqlClient
Public Class frm_add
Private Sub btt_add1_Click(sender As Object, e As EventArgs) Handles btt_add1.Click
Dim cn As New SqlConnection("Server=MR-TFP3T1B2E2IJ\SQLEXPRESSS; Database = 603data; Integrated Security=true")
Dim sql As String
Dim cmd As New SqlCommand
If txt_add_id.Text = "" Or txt_add_number.Text = "" Or txt_add_sex.Text = "" Or txt_add_name.Text = "" Or txt_add_lastname.Text = "" Or txt_add_nickname.Text = "" Or txt_add_birthday.Text = "" Or txt_add_blood.Text = "" Or txt_add_nationality.Text = "" Or txt_add_origin.Text = "" Or txt_add_religion.Text = "" Or txt_add_sex2.Text = "" Or txt_add_weight.Text = "" Or txt_add_height.Text = "" Or txt_add_id13.Text = "" Or txt_add_address.Text = "" Or txt_add_tumbol.Text = "" Or txt_add_district.Text = "" Or txt_add_province.Text = "" Or txt_add_zipcode.Text = "" Or txt_add_numberphone.Text = "" Or txt_add_motto.Text = "" Or txt_add_email.Text = "" Or txt_add_facebook.Text = "" Or txt_add_lineee.Text = "" Or txt_add_ig.Text = "" Then
MessageBox.Show("กรุณากรอกข้อมูลให้ครบด้วยครับ..", "คำเตือน", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)
Else
MessageBox.Show("คุณต้องการบันทึกข้อมูลใช่หรือไม่?", "ยืนยัน", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)