Private Sub Call_province()
Try
Dim sqlprovince As String = ""
sqlprovince = "SELECT * FROM province"
sqlprovince &= " ORDER BY PROVINCEID"
da = New SqlDataAdapter(sqlprovince, Conn)
da.Fill(ds, "province")
' If IsFind = True Then
'ds.Tables("province").Clear()
' End If
If ds.Tables("province").Rows.Count <> 0 Then
IsFind = True
With cboPROVINCE_TH
.DataSource = ds.Tables("province")
.DisplayMember = "PROVINCE_TH"
.ValueMember = "PROVINCEID"
.DataBindings.Clear()
.DataBindings.Add("SelectedValue", ds, "population.PROVINCEID")
End With
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
อันนี้เป็นโค้ดเต็ม ๆ
Code (VB.NET)
Option Explicit On
Option Strict On
Imports System.Windows.Forms.DataGridView
Imports System.Data
Imports System.Data.SqlClient
Public Class frmOwner
Dim Conn As SqlConnection = New SqlConnection
Dim da As SqlDataAdapter
Dim add_state As Boolean = False
Dim dt As New DataTable
Dim ds As DataSet = New DataSet()
Dim dc As DataSet = New DataSet()
Dim dd As New DataTable
Private bim As New BindingSource
Private bin As New BindingSource
Dim tmpFileName As String = ""
Dim pop As SqlCommand
Dim CurrentRecord As Integer
Dim ImageFileName As String = ""
Dim RecordCount As Integer
Dim objCurrencyMgr As CurrencyManager
Dim currRecPos As Integer
Dim addNewMode As Boolean
Public Property AllowNavigation As Boolean
Dim IsFind As Boolean = False
Dim cs As DataGridViewCellStyle
Private Sub Owner_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Showe1()
Call_province()
' call_amphur()
' call_tambon()
End Sub
Private Sub Call_province()
Try
Dim sqlprovince As String = ""
sqlprovince = "SELECT * FROM province"
sqlprovince &= " ORDER BY PROVINCEID"
da = New SqlDataAdapter(sqlprovince, Conn)
da.Fill(ds, "province")
' If IsFind = True Then
'ds.Tables("province").Clear()
' End If
If ds.Tables("province").Rows.Count <> 0 Then
IsFind = True
With cboPROVINCE_TH
.DataSource = ds.Tables("province")
.DisplayMember = "PROVINCE_TH"
.ValueMember = "PROVINCEID"
.DataBindings.Clear()
.DataBindings.Add("SelectedValue", ds, "population.PROVINCEID")
End With
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub call_amphur()
ds.Tables.Clear()
Try
Dim sqldistrict As String = ""
sqldistrict = "SELECT * FROM district"
If cboPROVINCE_TH.ValueMember = "" Then
Exit Sub
Else
sqldistrict &= " where PROVINCEID = '" & CStr(cboPROVINCE_TH.SelectedValue) & "'"
sqldistrict &= " ORDER BY DISTRICTID"
da = New SqlDataAdapter(sqldistrict, Conn)
da.Fill(ds, "district")
If ds.Tables("district").Rows.Count <> 0 Then
With cboDISTRICT_TH
.DataSource = ds.Tables("district")
.DisplayMember = "DISTRICT_TH"
.ValueMember = "DISTRICTID"
.DataBindings.Clear()
.DataBindings.Add("SelectedValue", ds, "population.DISTRICTID")
End With
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub call_tambon()
ds.Tables.Clear()
Try
Dim sqltambon As String = ""
sqltambon = "SELECT * FROM tambon"
If cboDISTRICT_TH.ValueMember = "" Then
Exit Sub
Else
sqltambon &= " where DISTRICTID = '" & CStr(cboDISTRICT_TH.SelectedValue) & "'"
sqltambon &= " ORDER BY TAMBONID"
da = New SqlDataAdapter(sqltambon, Conn)
da.Fill(ds, "tambon")
If ds.Tables("tambon").Rows.Count <> 0 Then
With cboTAMBON_TH
.DataSource = ds.Tables("tambon")
.DisplayMember = "TAMBON_TH"
.ValueMember = "TAMBONID"
.DataBindings.Clear()
.DataBindings.Add("SelectedValue", ds, "population.TAMBONID")
End With
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Dim sql As String
sql = "SELECT * FROM populationView_1"
da = New SqlDataAdapter(sql, Conn)
da.Fill(dc, "populationView_1")
DataGridView1.DataSource = dc.Tables("populationView_1")
' txtsearch.Clear()
Show1()
End Sub
Private Sub Show1()
Dim cs As New DataGridViewCellStyle
cs.Font = New Font("ms sans serif", 10, FontStyle.Regular)
cs.Alignment = DataGridViewContentAlignment.MiddleCenter
cs.ForeColor = Color.Blue
With DataGridView1
.ColumnHeadersDefaultCellStyle = cs
.Columns(0).HeaderText = "ลำดับ"
.Columns(1).HeaderText = "คำนำหน้าชื่อ"
.Columns(2).HeaderText = "ชื่อ"
.Columns(3).HeaderText = "นามสกุล"
.Columns(4).HeaderText = "บ้านเลขที่"
.Columns(5).HeaderText = "หมู่"
.Columns(6).HeaderText = "หมู่บ้าน"
.Columns(7).HeaderText = "ตำบล"
.Columns(8).HeaderText = "อำเภอ"
.Columns(9).HeaderText = "จังหวัด"
.Columns(10).HeaderText = "รหัสไปรษณี"
.Columns(0).Width = 40
.Columns(1).Width = 80
.Columns(2).Width = 80
.Columns(3).Width = 80
.Columns(4).Width = 60
.Columns(5).Width = 60
.Columns(6).Width = 70
.Columns(7).Width = 80
.Columns(8).Width = 80
.Columns(9).Width = 80
.Columns(10).Width = 70
.Columns(0).SortMode = DataGridViewColumnSortMode.NotSortable
.Columns(1).SortMode = DataGridViewColumnSortMode.NotSortable
.Columns(2).SortMode = DataGridViewColumnSortMode.NotSortable
.Columns(3).SortMode = DataGridViewColumnSortMode.NotSortable
.Columns(4).SortMode = DataGridViewColumnSortMode.NotSortable
.Columns(5).SortMode = DataGridViewColumnSortMode.NotSortable
.Columns(6).SortMode = DataGridViewColumnSortMode.NotSortable
.Columns(7).SortMode = DataGridViewColumnSortMode.NotSortable
.Columns(8).SortMode = DataGridViewColumnSortMode.NotSortable
.Columns(9).SortMode = DataGridViewColumnSortMode.NotSortable
.Columns(10).SortMode = DataGridViewColumnSortMode.NotSortable
End With
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim ofDlg As New OpenFileDialog()
ofDlg.Title = "เลือกไฟล์รูปภาพ"
ofDlg.Filter = "Bitmap Images(.bmp)|*.bmp|Gif Images(.gif)|*.gif|Jpeg Images(.jpg)|*.jpg| Png Image(*.png)|*.png|All Files (*.*)|*.*"
If ofDlg.ShowDialog = DialogResult.OK Then
tmpFileName = ofDlg.FileName
PictureBox1.Image = Image.FromFile(tmpFileName)
End If
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim sqlupdate As String
Dim sqladd As String
sqlupdate = "update population"
sqlupdate &= " set NAMECODE= '" & txtNAMECODE.Text & " ',"
sqlupdate &= " FIRSTNAME= '" & txtFIRSTNAME.Text & "',"
sqlupdate &= " LASTNAME= '" & txtLASTNAME.Text & "',"
sqlupdate &= " POPID= '" & txtPOP.Text & " ',"
sqlupdate &= " HOUSENO= '" & txtHOUSENO.Text & " ',"
sqlupdate &= " MOO= '" & txtMOO.Text & " ',"
sqlupdate &= " SOINAME= '" & txtSOINAME.Text & " ',"
sqlupdate &= " VILLAGENAME_TH= '" & txtVILLAGENAME_TH.Text & " ',"
sqlupdate &= " ZIPCODE= '" & txtZIPCODE.Text & " ',"
sqlupdate &= " TELEPHONE= '" & txtPHONE.Text & "',"
sqlupdate &= " EMAIL= '" & txtemail.Text & "',"
sqlupdate &= " PICTURE= '" & tmpFileName & "',"
sqlupdate &= " TAMBONID= '" & CStr(cboTAMBON_TH.SelectedValue) & "',"
sqlupdate &= " DISTRICTID= '" & CStr(cboDISTRICT_TH.SelectedValue) & "',"
sqlupdate &= " PROVINCEID= '" & CStr(cboPROVINCE_TH.SelectedValue) & "',"
sqlupdate &= " LASTUPDATE= '" & DateTimePicker1.Value & "',"
sqlupdate &= " PERSONTYPEID= '" & CStr(cboPERSONTYPE.SelectedValue) & "',"
sqlupdate &= " TITLEID='" & CStr(cboTITLENAME.SelectedValue) & "'"
sqlupdate &= " where PID = '" & txtPID.Text & "'"
sqladd = "insert into population (NAMECODE,FIRSTNAME,"
sqladd &= "LASTNAME,POPID,HOUSENO,MOO,SOINAME,"
sqladd &= "VILLAGENAME_TH,ZIPCODE,TELEPHONE,EMAIL,PICTURE,TAMBONID,DISTRICTID,"
sqladd &= "PROVINCEID,TITLEID,PERSONTYPEID,LASTUPDATE)"
sqladd &= " values ('" & txtNAMECODE.Text & "',"
sqladd &= "'" & txtFIRSTNAME.Text & "',"
sqladd &= "'" & txtLASTNAME.Text & " ',"
sqladd &= "'" & txtPOP.Text & " ',"
sqladd &= "'" & txtHOUSENO.Text & " ',"
sqladd &= "'" & txtMOO.Text & " ',"
sqladd &= "'" & txtSOINAME.Text & " ',"
sqladd &= "'" & txtVILLAGENAME_TH.Text & " ',"
sqladd &= "'" & txtZIPCODE.Text & " ',"
sqladd &= "'" & txtPHONE.Text & " ',"
sqladd &= "'" & txtemail.Text & " ',"
sqladd &= "'" & tmpFileName & "',"
sqladd &= "'" & CStr(cboTAMBON_TH.SelectedValue) & "',"
sqladd &= "'" & CStr(cboDISTRICT_TH.SelectedValue) & "',"
sqladd &= "'" & CStr(cboPROVINCE_TH.SelectedValue) & "',"
sqladd &= "'" & CStr(cboTITLENAME.SelectedValue) & "',"
sqladd &= "'" & CStr(cboPERSONTYPE.SelectedValue) & "',"
sqladd &= "'" & DateTimePicker1.Value & "')"
Try
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConnString
.Open()
End With
pop = New SqlCommand
With pop
.CommandType = CommandType.Text
If add_state = True Then
.CommandText = sqladd
Else
.CommandText = sqlupdate
End If
.Connection = Conn
.ExecuteNonQuery()
End With
Catch ErrorToEdit As Exception
MessageBox.Show(ErrorToEdit.Message & sqladd, "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try
add_state = False
MessageBox.Show("บันทึกข้อมูลเสร็จแล้ว ", "แจ้งให้ทราบ", MessageBoxButtons.OK, MessageBoxIcon.Information)
btnAdd.Enabled = True
btnEdit.Enabled = True
btnDelete.Enabled = True
btnSave.Enabled = True
btnLast.Enabled = True
btnNext.Enabled = True
btnPrevious.Enabled = True
btnFirst.Enabled = True
txtNAMECODE.BackColor = Color.White
txtFIRSTNAME.BackColor = Color.White
txtLASTNAME.BackColor = Color.White
txtPOP.BackColor = Color.White
txtPOP.BackColor = Color.White
cboROAD.BackColor = Color.White
txtHOUSENO.BackColor = Color.White
txtMOO.BackColor = Color.White
txtSOINAME.BackColor = Color.White
txtPARCEL_CODE.BackColor = Color.White
cboTAMBON_TH.BackColor = Color.White
cboDISTRICT_TH.BackColor = Color.White
cboPROVINCE_TH.BackColor = Color.White
txtZIPCODE.BackColor = Color.White
cboPERSONTYPE.BackColor = Color.White
txtREMARK.BackColor = Color.White
txtVILLAGENAME_TH.BackColor = Color.White
cboTITLENAME.BackColor = Color.White
txtPHONE.BackColor = Color.White
txtemail.BackColor = Color.White
End Sub
Private Sub ShowPosition()
Try
CurrentRecord = Me.BindingContext(ds, "population").Position + 1
RecordCount = Me.BindingContext(ds, "population").Count
lblRecord.Text = "" & CurrentRecord & " / " & RecordCount
If CurrentRecord > 0 Then
' If Convert.ToString(dt.Rows(CurrentRecord - 1).Item("LOCALID")) = "0" Then
'RadioButton1.Checked = True
' ElseIf Convert.ToString(dt.Rows(CurrentRecord - 1).Item("LOCALID")) = "1" Then
' RadioButton2.Checked = True
End If
If Convert.ToString(dt.Rows(CurrentRecord - 1).Item("PICTURE")) <> "" Then
PictureBox1.Image = Image.FromFile(Convert.ToString(dt.Rows(CurrentRecord - 1).Item("PICTURE")))
Else
PictureBox1.Image = Nothing
End If
' End If
Catch
PictureBox1.Image = Nothing
End Try
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
Me.BindingContext(ds, "population").Position += 1
ShowPosition()
btnPrevious.Enabled = True
btnFirst.Enabled = True
Call_province()
call_amphur()
call_tambon()
End Sub
Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click
Me.BindingContext(ds, "population").Position = 1
ShowPosition()
btnLast.Enabled = True
btnNext.Enabled = True
btnPrevious.Enabled = False
btnFirst.Enabled = False
Call_province()
call_amphur()
call_tambon()
End Sub
Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
Me.BindingContext(ds, "population").Position -= 1
ShowPosition()
btnLast.Enabled = True
btnNext.Enabled = True
Call_province()
call_amphur()
call_tambon()
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
Me.BindingContext(ds, "population").Position = -1
ShowPosition()
btnLast.Enabled = False
btnNext.Enabled = False
btnPrevious.Enabled = True
btnFirst.Enabled = True
Call_province()
call_amphur()
call_tambon()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
Dim sqlpop As String = ""
If MsgBox("คุณแน่ใจที่จะลบรายการนี้หรือไม่", MsgBoxStyle.YesNo, "ยืนยันการลบ") = MsgBoxResult.Yes Then
sqlpop = "delete from population where PID = '" & txtPID.Text & "'"
Try
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConnString
.Open()
End With
pop = New SqlCommand
With pop
.CommandType = CommandType.Text
.CommandText = sqlpop
.Connection = Conn
.ExecuteNonQuery()
End With
Catch ErrorToEdit As Exception
MessageBox.Show(ErrorToEdit.Message, "ลบข้อมูลไม่ได้", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try
' Call clear_text()
Showe1()
PictureBox1.Image = Nothing
End If
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
add_state = True
txtREMARK.BackColor = Color.LightYellow
cboROAD.BackColor = Color.LightYellow
txtSOINAME.BackColor = Color.LightYellow
cboPERSONTYPE.BackColor = Color.LightYellow
cboTITLENAME.BackColor = Color.LightYellow
txtFIRSTNAME.BackColor = Color.LightYellow
txtLASTNAME.BackColor = Color.LightYellow
txtNAMECODE.BackColor = Color.LightYellow
txtHOUSENO.BackColor = Color.LightYellow
txtMOO.BackColor = Color.LightYellow
txtPARCEL_CODE.BackColor = Color.LightYellow
txtPOP.BackColor = Color.LightYellow
txtPARCEL_CODE.BackColor = Color.LightYellow
txtVILLAGENAME_TH.BackColor = Color.LightYellow
txtPHONE.BackColor = Color.LightYellow
txtemail.BackColor = Color.LightYellow
'ส่วนของเจ้าของทรัพย์สิน
txtHOUSENO.BackColor = Color.LightYellow
txtMOO.BackColor = Color.LightYellow
txtPARCEL_CODE.BackColor = Color.LightYellow
cboTAMBON_TH.BackColor = Color.LightYellow
cboDISTRICT_TH.BackColor = Color.LightYellow
cboPROVINCE_TH.BackColor = Color.LightYellow
txtZIPCODE.BackColor = Color.LightYellow
clear_text()
End Sub
Private Sub cboPROVINCE_TH_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboPROVINCE_TH.SelectedValueChanged
call_amphur()
End Sub
Private Sub cboDISTRICT_TH_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboDISTRICT_TH.SelectedIndexChanged
call_tambon()
End Sub
Private Sub clear_text()
txtPID.Enabled = False
txtNAMECODE.Text = ""
txtFIRSTNAME.Text = ""
txtLASTNAME.Text = ""
txtPOP.Text = ""
txtHOUSENO.Text = ""
txtMOO.Text = ""
txtVILLAGENAME_TH.Text = ""
cboTAMBON_TH.Text = ""
cboDISTRICT_TH.Text = ""
cboPROVINCE_TH.Text = ""
txtZIPCODE.Text = ""
cboPERSONTYPE.Text = ""
cboTITLENAME.Text = ""
txtPHONE.Text = ""
txtemail.Text = ""
cboPROVINCE_TH.Text = ""
End Sub
Private Sub DataGridView1_CellMouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseUp
If e.RowIndex = -1 Then Exit Sub
With DataGridView1
' txtPID.Text = .Rows.Item(e.RowIndex).Cells(0).Value.ToString()
cboTITLENAME.Text = .Rows.Item(e.RowIndex).Cells(1).Value.ToString()
txtFIRSTNAME.Text = .Rows.Item(e.RowIndex).Cells(2).Value.ToString()
txtLASTNAME.Text = .Rows.Item(e.RowIndex).Cells(3).Value.ToString()
txtHOUSENO.Text = .Rows.Item(e.RowIndex).Cells(4).Value.ToString()
txtMOO.Text = .Rows.Item(e.RowIndex).Cells(5).Value.ToString()
txtVILLAGENAME_TH.Text = .Rows.Item(e.RowIndex).Cells(6).Value.ToString()
cboTAMBON_TH.Text = .Rows.Item(e.RowIndex).Cells(7).Value.ToString()
cboDISTRICT_TH.Text = .Rows.Item(e.RowIndex).Cells(8).Value.ToString()
cboPROVINCE_TH.Text = .Rows.Item(e.RowIndex).Cells(9).Value.ToString()
txtZIPCODE.Text = .Rows.Item(e.RowIndex).Cells(10).Value.ToString()
txtSOINAME.Text = .Rows.Item(e.RowIndex).Cells(12).Value.ToString()
cboROAD.Text = .Rows.Item(e.RowIndex).Cells(13).Value.ToString()
cboPERSONTYPE.Text = .Rows.Item(e.RowIndex).Cells(19).Value.ToString()
txtPHONE.Text = .Rows.Item(e.RowIndex).Cells(21).Value.ToString()
txtemail.Text = .Rows.Item(e.RowIndex).Cells(22).Value.ToString()
txtNAMECODE.Text = .Rows.Item(e.RowIndex).Cells(24).Value.ToString()
Try
PictureBox1.Image = Image.FromFile(.Rows.Item(e.RowIndex).Cells("PICTURE").Value.ToString())
Catch ex As Exception
PictureBox1.Image = Nothing
End Try
End With
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
frmsearch_Owner.ShowDialog()
End Sub
Private Sub Showe1()
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConnstring
.Open()
End With
Dim sqlpop As String
sqlpop = "SELECT * FROM population"
If IsFind = True Then
ds.Tables("population").Clear()
End If
da = New SqlDataAdapter(sqlpop, Conn)
da.Fill(ds, "population")
da.SelectCommand.CommandText = sqlpop
da.Fill(ds, "population")
If ds.Tables("population").Rows.Count <> 0 Then
IsFind = True
txtPID.DataBindings.Clear()
txtFIRSTNAME.DataBindings.Clear()
txtLASTNAME.DataBindings.Clear()
txtNAMECODE.DataBindings.Clear()
txtPOP.DataBindings.Clear()
txtemail.DataBindings.Clear()
txtPHONE.DataBindings.Clear()
txtHOUSENO.DataBindings.Clear()
txtMOO.DataBindings.Clear()
txtSOINAME.DataBindings.Clear()
txtPARCEL_CODE.DataBindings.Clear()
txtZIPCODE.DataBindings.Clear()
cboROAD.DataBindings.Clear()
' txtREMARK.DataBindings.Clear()
txtPID.DataBindings.Add("Text", ds, "population.PID")
txtFIRSTNAME.DataBindings.Add("Text", ds, "population.FIRSTNAME")
txtLASTNAME.DataBindings.Add("Text", ds, "population.LASTNAME")
txtNAMECODE.DataBindings.Add("Text", ds, "population.NAMECODE")
txtPOP.DataBindings.Add("Text", ds, "population.POPID")
txtemail.DataBindings.Add("Text", ds, "population.EMAIL")
txtPHONE.DataBindings.Add("Text", ds, "population.TELEPHONE")
txtHOUSENO.DataBindings.Add("Text", ds, "population.HOUSENO")
txtMOO.DataBindings.Add("Text", ds, "population.MOO")
txtSOINAME.DataBindings.Add("Text", ds, "population.SOINAME")
txtPARCEL_CODE.DataBindings.Add("Text", ds, "population.VILLAGENAME_TH")
' cboTAMBON_TH.DataBindings.Add("Text", ds, "population.TAMBON_TH")
'cboDISTRICT_TH.DataBindings.Add("Text", ds, "population.DISTRICT_TH")
' cboPROVINCE_TH.DataBindings.Add("Text", ds, "population.PROVINCE_TH")
txtZIPCODE.DataBindings.Add("Text", ds, "population.ZIPCODE")
cboROAD.DataBindings.Add("Text", ds, "population.ROADNAME")
' txtREMARK.DataBindings.Add("Text", ds, "population.REMARK")
dt = ds.Tables("population")
ShowPosition()
End If
Dim sqltitlecode As String = ""
sqltitlecode = "SELECT * FROM titlecode ORDER BY TITLEID"
da = New SqlDataAdapter(sqltitlecode, Conn)
da.Fill(ds, "titlecode")
With cboTITLENAME
.DisplayMember = "TITLE_NAME"
.ValueMember = "TITLEID"
.DataSource = ds.Tables("titlecode")
.DataBindings.Clear()
.DataBindings.Add("SelectedValue", ds, "population.TITLEID")
End With
Dim sqlperson As String = ""
sqlperson = "SELECT * FROM persontype ORDER BY PERSONTYPEID"
da = New SqlDataAdapter(sqlperson, Conn)
da.Fill(ds, "persontype")
With cboPERSONTYPE
.DisplayMember = "PERSON_DESC"
.ValueMember = "PERSONTYPEID"
.DataSource = ds.Tables("persontype")
.DataBindings.Clear()
.DataBindings.Add("SelectedValue", ds, "population.PERSONTYPEID")
End With
End Sub
End Class
Tag : .NET, Ms SQL Server 2008, Win (Windows App), VB.NET, VS 2010 (.NET 4.x)