Home
Link To Us
Components
Resources










Site Menu

An Overview in Utilizing ASP to Provide Database Access Through Web Browsers

An Overview in Creating an ActiveX DLL for Use with ASP Scripts

Search the Web for other ASP Tutorials

A Note From the Author

A Good ASP Database Resource
cover
More Resources




















Top Ranked
Reference Books









An Overview in Creating A DSN-Less Connection to A Database
by Derrald Farnsworth-Livingston

Choosing the type of connection we will be working with is the next task we must accomplish. We can choose any ODBC-complaint server but since we have a SQL Server 2000 machine we will want to use the SQL Server Driver. This can be accomplished in the first part of the string like this.

driver={SQL Server};

We will then want to choose the server. This can be the ip address or the netbios name of the machine. In this example we will use the netbios name. In addition, some database administrators choose to change the default port on which the server operates from 1433. This is fine and we can call that port from our string.

server=DB1;port=5000;

Thirdly, we will want to specify the username and password. In this example we will be calling a SQL Server userid. It is recommended to not use the sa user as the password must follow directly in the string. If anyone where to get a hold of your source code they would be able to open the database. I would create a read-only user, or a user that only has access to one view in the database.

uid=dataview;pwd=openme;

Lastly, we want to reference the database or view that we will be using for our data.

database=operations;

We have now specified all the required information to be put into the DNS-less string. We now put them together while making sure they are separated with semicolons and assign them to the ConnectionString property.

connection.ConnectionString="driver={SQL Server};server=DB1;port=5000;uid=dataview;pwd=openme;database=operations;"

We can then set the database timeout value.

connection.ConnectionTimeout = 100

Now the data in the database is ours to access if all the values have been inputted correctly. We shall open the database.

connection.Open

We can then create recordsets with the data to view. This is accomplished by creating the recordset and then calling the SQL statement against the database to fill the recordset.

SQLStmt = "Select * from services where op_id=34" Set rst = CreateObject("ADODB.Recordset") rst.Open SQLStmt, connection

The data has now been placed in the recordset and other tasks can be called against the data or the database. Setting up a DSN-less connection is the easiest and fastest way to begin to access information from ASP or Visual Basic.


Sections

Setting up a DSN-Less Connection

The Bookworm
Search the Tutorial-Web library for books on any topic!
Sponsors

Search Now:
In Association with Amazon.com