简体   繁体   中英

Connecting to SQL server in ASP

I'm sure this has been answered before, but every example I try I can't seem to connect to my SQL Server.

I'm using SQL Server 2014, and the webpage is being hosted in IIS on Windows 7 x64.

I'm trying to get my webpages to build themselves recursively from information in a database, I've configured IIS to run ASP pages (I believe its classic ASP as opposed to ASP.net, but I may be wrong)

I started by looking at examples that basically returned all entries in in a particular column in a table, however when i got error messages on trying to load the page:

An error occurred on the server when processing the URL. Please contact the system administrator.
If you are the system administrator please click here to find out more about this error.

I tried stripping it down to bare minimum, ie just opening the connection to the database.

And even then I get the same error, here are a few of the examples I tried:

Firstly if anyone could tell me how to debug it further, ie getting proper error messages that actually tell me something useful, that would be a good start.

If there's any information I missed then please ask.

If you've given your files the extension .asp then it is Classic ASP

Do you know what version of SQL Server you're using? If it's express then you need to say so in your connection string eg Data Source=yourserveraddress\\SQLEXPRESS

I recommend using the OLEDB method in Example 3 rather than the ODBC method in 1 and 2 but they should all work. This is a good resource for Connection Strings

http://www.connectionstrings.com/sql-server/

If you follow the steps on this page you will be able to see more useful error messages

http://www.chestysoft.com/asp-error-messages.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM