Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.ASP Connections

Status
Not open for further replies.

RussOSU

Technical User
Apr 16, 2001
93
0
0
US
I think I must just be plain retarded. Could someone help walk me through how to create a connection to a database. I do not understand what a DNS and all that crap is so please be as detailed as possible. I am really trying to learn this but I am just dumb when it comes to this I guess. Thanks for all of your help.

Russ
 
A DSN (Data source name) is a definition of where the ODBC driver can find your database. You should create a DNS at the Windows control panel and later use that name in the connection creation wizard at Ultradev.

Choose the ODBC icon at control panel ("ODBC Data Sources"). At the System DSN tab select your data base driver e.g. "Microsoft Access Driver (*.mdb)". Choose a name and fill the fields related to your database.

At UltraDev open a page, select Modify/Connections... Choose New, select the type of connection (ODBC) and put the name of the DSN that you created. Click on the Test button.

I hope this help.
 
And if you want to code the connection yourself (never a bad idea), then you can do:

dim con
set con = server.createObject("ADODB.Connection")
con.open ("DSN=dsnName;UID=uid;PWD=pwd")

So that the 'dsnName' is the name you gave your DSN, like bironman suggested, and UID is your user id, and PWD is the password for that user id. If you're using Access or some other db that doesn't need a password, then your string would look like this:

con.open ("DSN=myDSN")

You can then open a recordset like:

dim rs
set rs = server.createObject("ADODB.Recordset")
dim sql
sql = "SELECT * FROM someTable" 'any valid SQL statement
rs.activeConnection = con 'must be a valid connection obj
rs.open sql

And you now have a recordset populated with all the records from your 'someTable' table that is contained in the database you specified for your DSN.

Don't forget to set your objects = nothing when you're finished with them.

set rs = nothing
set con = nothing

hope that helps! :)
Paul Prewett
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top