Databing

เป็นโค้ดในส่วน Form_Load เท่านนั้นนะค่ะ

With Conn

If .State = ConnectionState.Open Then .Close()'เปิดฐานข้อมูล

 .ConnectionString = strConn

.Open()

 End With

 '......................................

 'เราจะใช้ภาษา SQL ในการเรียกดึงข้อมูลมูล/จัดการข้อมูล

 Dim sqlhistory As String = ""'

sqlhistory = "SELECT * FROM history"

 

...ตรวจสอบสถานะของข้อมูล

 

If IsFind = True Then

ds.Tables("history").Clear()

 

End If

 

'...............................

 

'ดึงข้อข้อมูลมาเก็บไว้ในตระกล้าที่เราสมมติขึ้นมา

da =New OleDbDataAdapter(sqlhistory, Conn)

da.Fill(ds, "history")

 

'.....ประมวลผลข้อมูลและพร้อมเอามาแสดง

 If ds.Tables("history").Rows.Count <> 0 Then

IsFind =True

 End If

TextBox1.DataBindings.Add("Text", ds, "history.code")

TextBox2.DataBindings.Add("Text", ds, "history.F_name")