Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_database_setup thread: ODBC Help...


Message #1 by andy@t... on Fri, 17 Jan 2003 02:47:01
Hello,

Just beginning with ASP and trying to connect to the SQL database locally 
( I have installed Win2K Professional , SQL EM and Front Page on my local 
PC).

Trying to connect to the database but got the below message :

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

I have created the DSN on my local PC and tested the connection and it is 
working ,below are the result :

Microsoft SQL Server ODBC Driver Version 03.80.0194

Running connectivity tests...

Attempting connection
Connection established
Verifying option settings
Disconnecting from server

TESTS COMPLETED SUCCESSFULLY!

Below is my coding :

<%@Language=VBScript%>

<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Testing Database</title>
</head>

<body>

<%

strnConn = "Driver={SQL Server};Server=ANDY;Initial Catalog=Test;User 
Id=test;Password=abcdef"

Dim adoConn		'Hold Connection string
Dim rsAuthors		'Hold Recordset
Dim strSQL		'Hold SQL statement

set adoConn = Server.CreateObject("ADODB.Connection")
adoConn.Open strConn 		' Set active connection to object

set rsAuthors = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM tblUser" 

rsAuthors.Open "strSQL" , strConn

Do while Not rsAuthors.EOF 
	Response.Write rsAuthors("user_login")
	rsAuthors.MoveNext
Loop

rsAuthors.Close
set rsAuthors = Nothing

adoConn.Close
set adoConn = Nothing


%>

</body>

</html>


Hope someone might help me.




Andy
Message #2 by "Thomas Martin" <tmartin@n...> on Thu, 16 Jan 2003 23:49:54 -0500
<%

strnConn = "Driver={SQL Server};Server=ANDY;Initial Catalog=Test;User 
Id=test;Password=abcdef"

Looks like a typo possibly with "strnConn" as you refer it as strConn
later on here:

rsAuthors.Open "strSQL" , strConn


Also try the <% Option Explicit %>, it does wonders in telling you where
your problems lie. 

Tom

-----Original Message-----
From: andy@t... [mailto:andy@t...] 
Sent: Friday, January 17, 2003 2:47 AM
To: ASP Database Setup
Subject: [asp_database_setup] ODBC Help...

Hello,

Just beginning with ASP and trying to connect to the SQL database
locally 
( I have installed Win2K Professional , SQL EM and Front Page on my
local 
PC).

Trying to connect to the database but got the below message :

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

I have created the DSN on my local PC and tested the connection and it
is 
working ,below are the result :

Microsoft SQL Server ODBC Driver Version 03.80.0194

Running connectivity tests...

Attempting connection
Connection established
Verifying option settings
Disconnecting from server

TESTS COMPLETED SUCCESSFULLY!

Below is my coding :

<%@Language=VBScript%>

<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Testing Database</title>
</head>

<body>

<%

strnConn = "Driver={SQL Server};Server=ANDY;Initial Catalog=Test;User 
Id=test;Password=abcdef"

Dim adoConn		'Hold Connection string
Dim rsAuthors		'Hold Recordset
Dim strSQL		'Hold SQL statement

set adoConn = Server.CreateObject("ADODB.Connection")
adoConn.Open strConn 		' Set active connection to object

set rsAuthors = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM tblUser" 

rsAuthors.Open "strSQL" , strConn

Do while Not rsAuthors.EOF 
	Response.Write rsAuthors("user_login")
	rsAuthors.MoveNext
Loop

rsAuthors.Close
set rsAuthors = Nothing

adoConn.Close
set adoConn = Nothing


%>

</body>

</html>


Hope someone might help me.




Andy
tmartin@n...
%%email.unsub%%


Message #3 by "Patrick Wong" <patrick@r...> on Fri, 17 Jan 2003 14:06:36 +0800
try to use:
        set strnConn = Server.CreateObject("ADODB.Connection")
        set rsAuthors = Server.CreateObject("ADODB.Recordset")
        strnConn .ConnectionString =  "DSN=X1;uid=X2; pwd=X3;"
        strnConn.Open

        strSQL = "SELECT * FROM tblUser"
        rsAuthors.Open strSQL , strConn

X1 is the name of DSN
X2 is the userid
X3 is the password



cheers,
patrick

----- Original Message -----
From: <andy@t...>
To: "ASP Database Setup" <asp_database_setup@p...>
Sent: Friday, January 17, 2003 2:47 AM
Subject: [asp_database_setup] ODBC Help...


> Hello,
>
> Just beginning with ASP and trying to connect to the SQL database locally
> ( I have installed Win2K Professional , SQL EM and Front Page on my local
> PC).
>
> Trying to connect to the database but got the below message :
>
> Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
> [Microsoft][ODBC Driver Manager] Data source name not found and no default
> driver specified
>
> I have created the DSN on my local PC and tested the connection and it is
> working ,below are the result :
>
> Microsoft SQL Server ODBC Driver Version 03.80.0194
>
> Running connectivity tests...
>
> Attempting connection
> Connection established
> Verifying option settings
> Disconnecting from server
>
> TESTS COMPLETED SUCCESSFULLY!
>
> Below is my coding :
>
> <%@Language=VBScript%>
>
> <html>
>
> <head>
> <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
> <meta name="ProgId" content="FrontPage.Editor.Document">
> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
> <title>Testing Database</title>
> </head>
>
> <body>
>
> <%
>
> strnConn = "Driver={SQL Server};Server=ANDY;Initial Catalog=Test;User
> Id=test;Password=abcdef"
>
> Dim adoConn 'Hold Connection string
> Dim rsAuthors 'Hold Recordset
> Dim strSQL 'Hold SQL statement
>
> set adoConn = Server.CreateObject("ADODB.Connection")
> adoConn.Open strConn ' Set active connection to object
>
> set rsAuthors = Server.CreateObject("ADODB.Recordset")
> strSQL = "SELECT * FROM tblUser"
>
> rsAuthors.Open "strSQL" , strConn
>
> Do while Not rsAuthors.EOF
> Response.Write rsAuthors("user_login")
> rsAuthors.MoveNext
> Loop
>
> rsAuthors.Close
> set rsAuthors = Nothing
>
> adoConn.Close
> set adoConn = Nothing
>
>
> %>
>
> </body>
>
> </html>
>
>
> Hope someone might help me.
>
>
>
>
> Andy
patrick@r...
%%email.unsub%%
>
>


Message #4 by "Andy" <andy@t...> on Fri, 17 Jan 2003 22:10:42 +0800
Ooooppss....thanks Tom..it is working now.So I have change the Server to the
actual SQL server name when I upload to my hosting server?I have created an
include file so that I may only change that only.

Thanks.


Andy
----- Original Message -----
From: "Thomas Martin" <tmartin@n...>
To: "ASP Database Setup" <asp_database_setup@p...>
Sent: Friday, January 17, 2003 12:49 PM
Subject: [asp_database_setup] RE: ODBC Help...


> <%
>
> strnConn = "Driver={SQL Server};Server=ANDY;Initial Catalog=Test;User
> Id=test;Password=abcdef"
>
> Looks like a typo possibly with "strnConn" as you refer it as strConn
> later on here:
>
> rsAuthors.Open "strSQL" , strConn
>
>
> Also try the <% Option Explicit %>, it does wonders in telling you where
> your problems lie.
>
> Tom
>
> -----Original Message-----
> From: andy@t... [mailto:andy@t...]
> Sent: Friday, January 17, 2003 2:47 AM
> To: ASP Database Setup
> Subject: [asp_database_setup] ODBC Help...
>
> Hello,
>
> Just beginning with ASP and trying to connect to the SQL database
> locally
> ( I have installed Win2K Professional , SQL EM and Front Page on my
> local
> PC).
>
> Trying to connect to the database but got the below message :
>
> Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
> [Microsoft][ODBC Driver Manager] Data source name not found and no
> default
> driver specified
>
> I have created the DSN on my local PC and tested the connection and it
> is
> working ,below are the result :
>
> Microsoft SQL Server ODBC Driver Version 03.80.0194
>
> Running connectivity tests...
>
> Attempting connection
> Connection established
> Verifying option settings
> Disconnecting from server
>
> TESTS COMPLETED SUCCESSFULLY!
>
> Below is my coding :
>
> <%@Language=VBScript%>
>
> <html>
>
> <head>
> <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
> <meta name="ProgId" content="FrontPage.Editor.Document">
> <meta http-equiv="Content-Type" content="text/html;
> charset=windows-1252">
> <title>Testing Database</title>
> </head>
>
> <body>
>
> <%
>
> strnConn = "Driver={SQL Server};Server=ANDY;Initial Catalog=Test;User
> Id=test;Password=abcdef"
>
> Dim adoConn 'Hold Connection string
> Dim rsAuthors 'Hold Recordset
> Dim strSQL 'Hold SQL statement
>
> set adoConn = Server.CreateObject("ADODB.Connection")
> adoConn.Open strConn ' Set active connection to object
>
> set rsAuthors = Server.CreateObject("ADODB.Recordset")
> strSQL = "SELECT * FROM tblUser"
>
> rsAuthors.Open "strSQL" , strConn
>
> Do while Not rsAuthors.EOF
> Response.Write rsAuthors("user_login")
> rsAuthors.MoveNext
> Loop
>
> rsAuthors.Close
> set rsAuthors = Nothing
>
> adoConn.Close
> set adoConn = Nothing
>
>
> %>
>
> </body>
>
> </html>
>
>
> Hope someone might help me.
>
>
>
>
> Andy
> tmartin@n...
> %%email.unsub%%
>
>
>
%%email.unsub%%
>
>
>

Message #5 by "Ken Schaefer" <ken@a...> on Mon, 20 Jan 2003 16:28:11 +1100
Yes, or you can probably use:

Server=(local);

if you are using the default SQL Server instance, and the SQL Server is on
the same machine as the webserver.

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Andy" <andy@t...>
Subject: [asp_database_setup] RE: ODBC Help...


: Ooooppss....thanks Tom..it is working now.So I have change the Server to
the
: actual SQL server name when I upload to my hosting server?I have created
an
: include file so that I may only change that only.
:
: Thanks.


  Return to Index