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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting ODBC error

Status
Not open for further replies.

BryanF

Programmer
Nov 21, 2001
18
0
0
US
dim strSQL
dim cmdObject

set DatabaseConnection = Server.CreateObject("ADODB.Connection")
DatabaseConnection.Open "DSN=pubs", "sa", ""

set cmdObject=server.CreateObject("ADODB.Command")
set cmdObject.ActiveConnection=DatabaseConnection

these are the first six lines of code in a sub called WriteRecord(out of an exercise in a book) DatabaseConnection.Open is on line 25. This is my error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/TitleMaintenance/InsertbookTitle.asp, line 25

as you can see i'm connecting to the pubs database installed with SQL server, and i do have my data view open showing me the database. Any ideas what is wrong?
 
Remove the word "DSN=" from the DatabaseConnection.Open "DSN=pubs", "sa", ""
and try.
 
still didn't work. i get the same error on the same line number. I would give up, but i moved on to my next project and am still having trouble using some pages.... i can't even get them to display... so now i'm convinced it's a server issue... if anyone can give me a clue as to what to look for it would be greatly appreciated.
TIA
Bryan F
 
Have you made any DSN file yet ??
First when u want to test to open a database connection using DSN (as in your example), u have to make sure that in your web server has this DSN file.

If not, u can create in Control Panel - ODBC Data Source

In there you add 1 connection, & name it pubs .. or any other name.

Or u don't have to add DSN file. but using a help in ADO control (VB 6.0). u just copy & paste the connection string that u build.

example : (for Ms Access)
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\dbFileName.mdb")& ";Persist Security Info=False;Jet OLEDB:Database Password=db_password"

example : (for SQL server)
Conn.open "DRIVER={SQL Server};UID=your_ID;PWD=your_password;DATABASE=Db_name;SERVER=SerVer_Name;"

Hope it will help :p

Regards,
JJ26

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top