'TODO: This line of code loads data into the 'Top_CustomerEntryDataSet3.Department' table. You can move, or remove it, as needed.
Me.DepartmentTableAdapter1.Fill(Me.Top_CustomerEntryDataSet3.Department)
'TODO: This line of code loads data into the 'Top_CustomerEntryDataSet1.titleTH' table. You can move, or remove it, as needed.
' Me.TitleTHTableAdapter.Fill(Me.Top_CustomerEntryDataSet1.titleTH)
Me.SubdeptIDTableAdapter.Fill(Me.Top_CustomerEntryDataSet.SubdeptID)
Try
MsgBox("เชื่อมได้แล้ว ")
Dim objConn As New SqlConnection
Dim objCmd As SqlCommand
Dim dtAdapter As New SqlDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
Dim strConnString, strSQL As String
strConnString = "Data Source=PONGWICS2014-PC; Initial Catalog=Top_CustomerEntry;User ID=sa;Password=Pong"
objConn.ConnectionString = strConnString
objConn.Open()
strSQL = "SELECT ID,DepartmentID FROM Department ORDER BY ID ASC "
objCmd = New SqlCommand
With (objCmd)
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds)
dt = ds.Tables(0)
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
id.DataSource = dt
id.DisplayMember = "ID"
id.ValueMember = "DepartmentID"
Catch ex As Exception
MsgBox("โอ้ๆ มันเกิดอะไรขึ้น ")
End Try
End Sub
Tag : .NET, Ms SQL Server 2008, Ms SQL Server 2012, VB.NET, VS 2008 (.NET 3.x), VS 2010 (.NET 4.x)