|
-
Nov 20th, 2002, 07:01 AM
#1
Thread Starter
Lively Member
vb.net sqlconnection err
Hi
i got the error
type is not defined: 'SqlConnection'
How to add a reference to Sql in VB.Net??
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
' Open a connection to the database.
Dim strConnection As String = _
"Data Source=192.168.0.1; Initial Catalog=Northwind;" _
& "Integrated Security=True"
Dim cn As SqlConnection = New SqlConnection(strConnection)
cn.Open()
' Set up a data set command object.
Dim strSelect As String = "SELECT * FROM Customers WHERE City = 'London'"
Dim dscmd As New SqlDataAdapter(strSelect, cn)
' Load a data set.
Dim ds As New DataSet()
dscmd.Fill(ds, "LondonCustomers")
' Close the connection.
cn.Close()
' Do something with the data set.
Dim dt As DataTable = ds.Tables.Item("LondonCustomers")
Dim rowCustomer As DataRow
For Each rowCustomer In dt.Rows
Response.Write(rowCustomer.Item("CompanyName"))
Next
End Sub
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|