<% noads=1 %> <%dim crumb crumb="SQL/Server ODBC Method" Crumb2="SQL Server ODBC Connection Method " crumb1="ODBC Database Connection Example" %> ADO ODBC Driver for SQL Server Connection Example
Home  Fees/Services  Access Examples  Programming Tutorials  Access Download  Articles  Search  Contact  Privacy  Links
  <%if len(crumb2)>2 then response.write crumb2 %>
 <% response.write crumb1 %>
 Home > MS Access Tutorials > Connection Strings<% response.write " > " & crumb %>

<% dim Gnum,Ynum Gnum="0957644070" Ynum="7867" dim Page_Type Page_Type="Prog" %>






Connect String to Access DSN

Connect String to OLEDB Provider for Jet

Database Connect String to Remote Database

ADO File-DSN Database Connection String

Access DSN-Less Connection String

SQL/Server ODBC Database Connection Method Example

OLE DB UDL Database Connection String Example

Connection Open Method String Example

Microsoft Office:
  MS Access 2003
  Access 2007
  Access 2010
  Access 2013


Microsoft Activex Data Object - ADO

Using the SQL Server ODBC Connection String Method

Here are two common connection methods for SQL/Server, one for standard security and one for Trusted Connections.

Dim conn as ADODB.Connection
Dim rst as ADODB.Recordset
Dim sql as string

'---------------

Regular/standard security:
Conn.Open "Driver={SQL Server};" & _
                   "Server=your_sqlserver_name;" & _
                   "Database=your_database_name;" & _
                   "UID=username;" & _
                   "PWD=password;"

Trusted connection security:
Conn.Open "Driver={SQL Server};" & _
                   "Server=your_sqlserver_name;" & _
                   "Database=your_database_name;" & _
                   "UID=;" & _
                   "PWD=;"

To have the computer ask for username and password:
Conn.Properties("Prompt") = adPromptAlways
Conn.Open "Driver={SQL Server};" & _
                   "Server=your_sqlserver_name;" & _
                   "Database=your_database_name;" & _

Where:
your_sqlserver_name = Name of the SQL Server instance.

your_database_name = The name of your database, such as Customer_Orders.

username = the username you have identified in the database, or the default 'Admin' username.

password = the password you have setup in the database or nothing  "Pwd=;" for no password.

'--------------  here we use the connection

sql = "select sales_rep, dollars from sales_by_rep_chart"

Set rst = Server.CreateObject("ADODB.Recordset")
rst.Open sql, conn, 3, 3
Set Session("mysession") = rst
rst.movefirst
response.write rst!sales_rep

'--------------

Where mysession is any name for the session.

When done with the recordset don't forget to close it:

Conn.close
set conn=nothing

 



















Contact Information

<% Response.write "Copyright 2000-" & year(now) & " Blue Claw Database Design" %>