943,199 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 1473
  • ASP RSS
You are currently viewing page 1 of this multi-page discussion thread
Jun 17th, 2010
0

ASP connect to SQL server 2005

Expand Post »
I've been googling for a few days and have tried all kinds of connection strings, but none have worked so far. I have a webpage on one server (using ASP NOT ASP.NET) trying to connect to a SQL database on another server (SQL 2005 server). I tried connecting using .net on another page and I just added a SqlDataSource tool and that works so I know there isn't a block between the servers. I think it must be my connection string.

Here are some of the connection strings I've tried (they all have different error messages and error out at the conn.open):

ASP Syntax (Toggle Plain Text)
  1. set conn=Server.CreateObject("ADODB.Connection")
  2. cst = "Driver={SQL Server};Server=111.111.11.11;Database=dbname;UID=domain\user;PWD=password"
  3. conn.Open(cst)
------------------
ASP Syntax (Toggle Plain Text)
  1. conn.ConnectionString="driver={SQL Server};server=servername;uid=domain\user;pwd=password;"
  2. conn.Open
  3. conn.DefaultDatabase="dbname"
------------------
ASP Syntax (Toggle Plain Text)
  1. conn.Open "Provider=SQLNCLI;Server=111.111.11.11;Database=dbname;UID=domain\user;PWD=password;"
  2. -----------------
  3. conn.ConnectionString="Driver={SQL Server};Server=111.111.11.11;Initial Catalog=dbname;User Id=domain\user;Password=password;Trusted_Connection=True;"
  4. conn.Open
  5. ---------------------
  6. conn.Open "Provider=SQLOLEDB; Data Source = 111.111.11.11; Initial Catalog = dbname; User Id = domain\user; Password=password;"
  7. ----------
  8. conn.Open "Provider=SQLOLEDB;Password=password;Persist Security Info=True;User ID=domain\user;Initial Catalog=dbname;Data Source=servername"
  9. -----------------------
  10. cst = "Provider=SQLOLEDB;" & _
  11. "Data Source=111.111.11.11;" & _
  12. "Initial Catalog=dbname;" & _
  13. "Network=DBMSSOCN;" & _
  14. "User Id=domain\user;" & _
  15. "Password=password"
  16. conn.open cst

The last connection string has this error:
Microsoft OLE DB Provider for SQL Server error '80040e4d'

Login failed for user 'domain\user'.

-------------

maybe it is a server setting, but I have looked on the SQL server management studio and that user is in the security list and I can log on to the server using that username and password. The ip on here is not real, but I made sure it is correct on the real page.

I would appreciate any kind of advice or suggestion. Thank you!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
webber1 is offline Offline
5 posts
since Jun 2010
Jun 18th, 2010
0
Re: ASP connect to SQL server 2005
Is that the Express (Free) version?
Reputation Points: 5
Solved Threads: 14
Junior Poster
ArtistScope is offline Offline
146 posts
since Jun 2010
Jun 18th, 2010
0
Re: ASP connect to SQL server 2005
Is that the Express (Free) version?
Hello. It's not express.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
webber1 is offline Offline
5 posts
since Jun 2010
Jun 18th, 2010
0
Re: ASP connect to SQL server 2005
This one used to work for me in a similar scenario...

strCon = "Provider=SQLOLEDB;Server=" & strServerName & ";User ID=" & strUserName & ";Password=" & strPassword & ";Database=" & strDatabaseName & ";"

The Server name could be an IP address or if it's a name then it needs to added to the server's ODBC list.

Or the problem could be a permissions thing... these days we are using SQL 2005 Express and I can never get them set up without calling in a partner :-)
Last edited by ArtistScope; Jun 18th, 2010 at 12:59 am.
Reputation Points: 5
Solved Threads: 14
Junior Poster
ArtistScope is offline Offline
146 posts
since Jun 2010
Jun 18th, 2010
0
Re: ASP connect to SQL server 2005
Thank you ArtistScope! I tried the string and still get "Login failed for user". Yeah..it must be a permissions thing somewhere...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
webber1 is offline Offline
5 posts
since Jun 2010
Jun 18th, 2010
0
Re: ASP connect to SQL server 2005
Maybe it's the account type that you trying to access with?

I think it needs to be for remote use. On ours we use "sa" as the remote user which is not an administrator on the SQL server. But this is the part I never got right either.
Reputation Points: 5
Solved Threads: 14
Junior Poster
ArtistScope is offline Offline
146 posts
since Jun 2010
Jun 18th, 2010
0
Re: ASP connect to SQL server 2005
Maybe it's the account type that you trying to access with?

I think it needs to be for remote use. On ours we use "sa" as the remote user which is not an administrator on the SQL server. But this is the part I never got right either.
So you made an account and set that account in SQL Server Management Studio to have the sysadmin role?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
webber1 is offline Offline
5 posts
since Jun 2010
Jun 25th, 2010
0
Re: ASP connect to SQL server 2005
I think you have to set the connection as a trusted site in the application properties.
Last edited by Ezzaral; Jul 6th, 2010 at 5:34 pm. Reason: Snipped "fake sig" link. Please restrict such links to your site-wide user signature, which can be edited from the user control panel.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
meganjo is offline Offline
1 posts
since Jun 2010
Jun 29th, 2010
0
Re: ASP connect to SQL server 2005
Hello. Thank you for all the suggestions. Where do I find the application properties?

I went to connectionstrings.com and tried these two strings from that site for trusted connections:
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
and
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

They both get errors:
"Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;"
gets this error:
Microsoft OLE DB Service Components error '80040e21'
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.

"Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;"
gets this error:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I'm googling the errors now so I will repost if find a solution. But please let me know if someone has advice. Thank you!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
webber1 is offline Offline
5 posts
since Jun 2010
Jun 29th, 2010
0
Re: ASP connect to SQL server 2005
I think that it may mean a "trusted site" or user in the SQL server properties.
Reputation Points: 5
Solved Threads: 14
Junior Poster
ArtistScope is offline Offline
146 posts
since Jun 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: User authentication and Duplicate record key
Next Thread in ASP Forum Timeline: asp how to develop Web Games





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC