Dim conn As New SqlConnection() Dim comm As New SqlCommand() Dim dr As SqlDataReader Dim connString As String Dim customerName As String connString = "Initial Catalog=Northwind;" connString += "Data Source=Office1\Test;" connString += "uid=test;pwd=password;" conn = New SqlConnection(connString)
With comm .Connection = conn .CommandText = "SELECT * FROM Northwind.dbo.Customers" .CommandType = CommandType.Text conn.Open() End With
dr = comm.ExecuteReader()
While (dr.Read()) If Not (dr.Item(2) Is System.DBNull.Value) Then customerName = CStr(dr.Item(2)) End If End While |