Solved

sql server connection not getting established in asp on localhost

Posted on 2008-10-18
9
478 Views
Last Modified: 2008-10-18
Hi
I was trying to create an asp applicaiton on my windows xp professional with sql server installed with windows authentication. The system name is SYSTEMP.

When I ran the asp page with the attached code snippet, I am getting the error message "Microsoft OLE DB Provider for SQL Server (0x80004005) Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection."

 Please tell me what is wrong with the connection string and how it should be corrected.
thanks
Kay
Dim cn 

Set cn = Server.Createobject("ADODB.Connection")

cn.connectionstring  = "Provider=SQLOLEDB; Data Source=SYSTEMP ; Initial Catalog=example; UID=sa; Password=;"

cn.open

Open in new window

0
Comment
Question by:seakay
  • 5
  • 4
9 Comments
 
LVL 7

Accepted Solution

by:
bluV11t earned 50 total points
Comment Utility
Hi!
Check out http://www.connectionstrings.com/?carrier=sqlserver

I always prefer setting up a DSN connection in ODBC manager (Control Panel/Administrative tools/Data Sources (ODBC)) with username and password and test the connection there. If you do this the cn.connectionstring = "DSN=yourDSNname;"
0
 
LVL 7

Assisted Solution

by:bluV11t
bluV11t earned 50 total points
Comment Utility
The connectionstring in it self is not wrong but with windows authentication on the server you need somthing different. Here is a similar question:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_22802136.html
0
 

Author Comment

by:seakay
Comment Utility
Thanks bluV11t for your reply.
I tried out your suggestion and created a dsn named test
Then i gave the following connection string

 cn.connectionstring  = "Provider=SQLOLEDB;   dsn=test"
But now it gives the errow message
Microsoft OLE DB Provider for SQL Server (0x80004005) Invalid connection string attribute

Please advise
Thanks
Kay
0
 

Author Comment

by:seakay
Comment Utility
Thanks bluV11t for your reply.
I tried out differnt strings as suggested in your link.
Later I tried changing the windows authentication to windows and sql server authentication
and gave the connection string as :
Provider=SQLOLEDB;   Data Source=SYSTEMP; Intial Catalog=example; uid=sa;Password=

I had tried earlier with windows login user id and password

The error message is still
Microsoft OLE DB Provider for SQL Server (0x80004005)
Invalid connection string attribute.

Any other suggestions? Please advise

Thanks
Kay
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 7

Expert Comment

by:bluV11t
Comment Utility
Hi! If you use dsn you dont need provider. Try just cn.connectionstring = "dsn=test;"
0
 

Author Comment

by:seakay
Comment Utility
Hi
Thanks bluV11t for your reply.
Tried cn.connectionstring = "dsn=test;"
but got
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

But when I tested the connection, it said that it was a success.
What am I doing wrong? Please help
Thanks
Kay
0
 
LVL 7

Expert Comment

by:bluV11t
Comment Utility
Did you set it up as a system DSN? Is it named "test"?
0
 

Author Comment

by:seakay
Comment Utility
HI
Thanks bluV11t for your reply.
Yes I had set up an ODBC connection to the required database with the name test tried with both windows authentication and sql server authentication. The result was the same

Should I change some settings in the SQL server side? or elsewhere?
Thanks for your replies so far. Please help
Thank you
Kay
0
 

Author Comment

by:seakay
Comment Utility
Hi
Thank you for your help
The following connections string worked for me.
 "Provider=SQLOLEDB; Data Source=(local) ; Initial Catalog=example;Persist Security Info=False;uid=sa;Password=;"

The follwoing link helped:
http://www.carlprothman.net/Default.aspx?tabid=87#OLEDBProviderForSQLServer

Thanks
Kay
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now