Web Site Creator Web Hosting Help
   Using SQL with ADO.NET

To give your page access to the classes you will need to perform SQL data access, you must import the System.Data and System.Data.SqlClient namespaces into your page.

'Do not forget to import

Dim myDataReader As SqlDataReader
Dim mySqlConnection As SqlConnection
Dim mySqlCommand As SqlCommand

'your connection properties
Dim mydatabaseserver As String = "database1.ehost-services.com"
Dim mylogin As String = "yourlogin"
Dim mypassword As String = "yourpassword"

mySqlConnection = New SqlConnection("server=" & mydatabaseserver & ";password=" & mypassword & ";user id=" & mylogin)
mySqlCommand = New SqlCommand("SELECT col1, col2 FROM mytable", mySqlConnection)

'open connection
myDataReader = mySqlCommand.ExecuteReader(CommandBehavior.CloseConnection)

'loop records here
Do While (myDataReader.Read())
Response.Write("<br>col1=" & myDataReader.GetValue(0) & " and col2=" & myDataReader.GetValue(1))

' Always call Close when done reading.
If Not (myDataReader Is Nothing) Then
End If

' If connection is open then close it when done.
If (mySqlConnection.State = ConnectionState.Open) Then
End If

Sign Up Now! Overview

Questions? Call sales at
1 (425) 974-4688
Or try our
Visit our Help Center where you can get simple and quick product support.
bulkregister.com   is an affiliate of   , a leading domain name services company.
Copyright © 1999-2019 BulkRegister. All rights reserved. Terms & Conditions | Privacy Policy | Abuse Policy