Click here to Skip to main content
15,891,745 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing an application in Classic ASP
My database is SQLSErver 2008
I am getting a problem in connecting to my database.
Here is the code which i used to connect.
connstring ="server=mymsever;database=mydb;Trusted_Connection=Yes;"
set conntemp = server.createobject("ADODB.Connection")
conntemp.ConnectionString=connstring
conntemp.Open()
Response.Write(conntemp.State)

The last statement is for the confirmation that is my connection status open or not. But each time i get 0 as printed which means its closed.
What to do in this case. How to connect it.
Posted

Are you using On Error Resume Next. If you are, you may be hiding an exception that is occuring on conntemp.Open(). Ensure that you remove the On Error Resume Next if you are using it and then diagnose the error you receive. If you aren't receiving an error of any kind, then your connection string may be wrong or there is a problem somewhere else in the code causing you the issue.
 
Share this answer
 
Thanx Mr. Marcus.

I tried that, and i got this error.

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)<br />
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified


Do you have any suggestions regarding this error
 
Share this answer
 
Here you go
OP wrote:
I tried that, and i got this error.

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Do you have any suggestions regarding this error

This usually happens in one of the following scenarios:(Quote taken from below link)

# you referenced your connection incorrectly (e.g. spelled the DSN name, or one of the DSN-less string components wrong);
# you referenced a DSN that doesn't exist;
# the user connecting to the DSN or DSN-less connection doesn't have access to the information stored in the registry (see KB #306345);
# you used an English or localized driver detail for your connection string when your system is not set up in that language (see KB #174655); or,
# you are missing the connection string entirely (this can happen if you maintain your connection string in a session variable, and your sessions aren't working; see Article #2157).
80004005 Errors[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900