ASP MS-SQL server 2008 connection string

Hi i am trying to connect to MS-SQLSERVER-2008 from asp. when i am running the asp page. i am getting this error

Error:

An error occurred on the server when processing the URL. Please contact the system administrator. 

What is the cause for this error. and is anything wrong in my code causing this error?

code:

<html>
<head>
</head>
<body>
<%
Dim Connection
Dim Recordset
Dim SQL

Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
Connection.open "Driver={SQL Server};Server=127.0.0.1;Database=products;UID=sa;PWD=sa","sa","sa"
SQL = "SELECT * FROM dbo.products_images"
Recordset.Open SQL,Connection;
If Recordset.EOF Then
Response.Write("No records returned.")
Else
Do While NOT Recordset.Eof   
Response.write Recordset("ID")
Response.write Recordset("product_id")
Response.write Recordset("im_name")
Response.write Recordset("im_type")
Response.write "<br>"   
Recordset.MoveNext    
Loop
End If
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing
%>
</body>
</html>

when i add below line, i am getting error.

Connection.open "Driver={SQL Server};Server=127.0.0.1;Database=products;UID=sa;PWD=sa","sa","sa"

How can i resolve this?

Answers


Are you using the express version of SQL Server? If you are you need to put "\SQLEXPRESS" after the server name - eg "Server=127.0.0.1\SQLEXPRESS;Database=..."

You're using an ODBC connection string, which should work, but with SqlServer 2008 you would be better off looking at Native Client 10 or even OLEDB - see the links below

http://www.connectionstrings.com/sql-server-native-client-10-0-oledb-provider/

http://www.connectionstrings.com/microsoft-ole-db-provider-for-sql-server-sqloledb/


<html>
<head>
</head>
<body>
<%
Dim Connection
Dim Recordset
Dim SQL

Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
Connection.open "Driver={SQL Server};Server=127.0.0.1;Database=products;UID=sa;PWD=sa"
SQL = "SELECT * FROM dbo.products_images"
Recordset.Open SQL,Connection

If Recordset.EOF Then
If Recordset.EOF Then
Response.Write("No records returned.")
Else
Do While NOT Recordset.Eof   
Response.write Recordset("Dept_Id")
Response.write Recordset("Dept_Name")
Response.write "<br>"   
Recordset.MoveNext    
Loop
End If
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing
%>
</body>
</html>

Need Your Help

cc1plus.exe: error: unrecognized command line option '-std=c++11' Netbeans 7

c++ c++11 netbeans-7

I'm trying to set up C++11 in Netbeans 7.3, however I seem to have hit a wall. The error I'm getting is the same as in the title:

How to accept 'theirs-conflict' to resolve tree conflict: Local add, incoming add upon merge

svn merge tree-conflict

I have come across the following basic Tree conflict: Local add, incoming add upon merge.