Imports System
Imports System.Data.SqlClient
Dim sConnection As String = "Provider=SQLOLEDB.1;Data Source=(local);User ID=sqlusername;Password=sqlpassword;Initial Catalog=CD;Persist Security Info=True;"
Dim SQL As String
SQL = "SELECT Field1, Field2 From Table"
Dim sqlConn As New OleDb.OleDbConnection(sConnection)
Dim sqlDataAdapter As New OleDb.OleDbDataAdapter(SQL, sqlConn)
Dim sqlDS As New DataSet("Table")
Dim sqlDV As DataView
Try
sqlConn.Open()
Catch ex As Exception
Msgbox(ex.Message)
End Try
If sqlConn.State = ConnectionState.Open Then
Try
sqlConn.Close()
Dim sqlTable As DataTable
sqlTable = sqlDS.Tables("Table1")
sqlDV = sqlTable.DefaultView
textBox1.DataBindings.Add("Text", sqlDV, "Field2")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
Imports System.Data.SqlClient
Dim sConnection As String = "Provider=SQLOLEDB.1;Data Source=(local);User ID=sqlusername;Password=sqlpassword;Initial Catalog=CD;Persist Security Info=True;"
Dim SQL As String
SQL = "SELECT Field1, Field2 From Table"
Dim sqlConn As New OleDb.OleDbConnection(sConnection)
Dim sqlDataAdapter As New OleDb.OleDbDataAdapter(SQL, sqlConn)
Dim sqlDS As New DataSet("Table")
Dim sqlDV As DataView
Try
sqlConn.Open()
Catch ex As Exception
Msgbox(ex.Message)
End Try
If sqlConn.State = ConnectionState.Open Then
Try
sqlConn.Close()
Dim sqlTable As DataTable
sqlTable = sqlDS.Tables("Table1")
sqlDV = sqlTable.DefaultView
textBox1.DataBindings.Add("Text", sqlDV, "Field2")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If