Dim sqlPrename As String
sqlPrename = "SELECT * FROM Prename ORDER BY PrenameCode"
Dim dtPrename As DataTable
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
With com
.CommandType = CommandType.Text
.CommandText = sqlPrename
.Connection = Conn
dr = .ExecuteReader()
If dr.HasRows Then
dtPrename = New DataTable()
dtPrename.Load(dr)
bsPrename = New BindingSource()
bsPrename.DataSource = dtPrename
With cboPrename
.DataSource = dtPrename
.DisplayMember = "PrenameName"
.ValueMember = "PrenameCode"
bdPrename = .DataBindings.Add("SelectedValue", bsPrename, "PrenameCode", True)
End With
Else
MessageBox.Show("ไม่มีข้อมูลคำนำหน้าชื่อ...กรุณาเพิ่มข้อมูลคำนำหน้าชื่อก่อน!!!", "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End With