Brinkster Knowledge Base

KB Home   /  Support  /  Database  /  MS SQL  /   How do I connect to a MS SQL database with ASP.NET 1.1
How do I connect to a MS SQL database with ASP.NET 1.1 Articles

Be sure to make note of the following when using these coding examples:

1. Replace username with your Brinkster hosting account username.
2. Replace password with the password for the account used above.
3. Your specific SQL server hostname is listed in Website Settings of the Control Panel.

*Your specific SQL server is listed in Website Settings of the account control panel (it is not SQL??).

<%@ Page language="VB" %>

<%

        Dim MyConString As String = "Data Source=SQL??.Brinkster.com" & _

        ";User ID=username" & _

        ";Password=password" & _

        ";Initial Catalog=username;"

 

    Dim oConn As New System.Data.SqlClient.SqlConnection

    Dim oCom As System.Data.SqlClient.SqlCommand

    Dim oDr As System.Data.SqlClient.SqlDataReader

    Dim sSQL As String

 

    sSQL = "SELECT * FROM MyTable"

 

    oConn.ConnectionString = MyConString

    oConn.Open()

 

    oCom = New System.Data.SqlClient.SqlCommand(sSQL, oConn)

 

    oDr = oCom.ExecuteReader()

 

    Do While oDr.Read()

          ' Show database data

    Loop

 

    oConn.Close()

%>