Thursday, March 29, 2012

Can't Connect

Win 2000, sqlServer 2000 Personal edition
Trying ot connect using .asp Vb Script
1. Sql server set to use Windows Authentication
2. Log onto Windows 2000 as Jim Bunton {no password)
3 Server 'Study' running ok
4. sql query analyser
i. "SELECT User_Name > dbo
ii. [using database NorthWind]
"SELECT * FROM Customers" > gives expected result
5. VB script
** BEGIN CODE connect.asp ***
<%
@. LANGUAGE="VBSCRIPT"
%>
<%
Option explicit
response.expires = 0
%>
<!-- #include file="adovbs.inc" -->
<html>
<head>
<title></title>
</head>
<body>
<%
dim Cn, CnStr
Set Cn = Server.CreateObject("ADODB.Connection")
Cn.ConnectionTimeOut = 1
Cn.provider="sqloledb"
response.write "Conn Provider is " & Cn.provider
CnStr="Data Source=Study;Initial Catalog=Norhwind;User
Id=sa;Password=;"
' Tried all sorts of user id's and paswords
'CnStr="Data Source=Study;Initial Catalog=Norhwind;User Id = 'Jim
Bunton';Password=;"
'CnStr="Data Source=Study;Initial Catalog=Norhwind;User Id
=dbo;Password=;"
'CnStr="Data Source=Study;Initial Catalog=Norhwind;User Id =
JimBunton;Password=;"
'CnStr="Data Source='Study';Initial Catalogue='Norhwind';User Id
='Study\Jim Bunton';Password=;"
%>
<p>--</p>
<%
response.write "Cnstr = " & CnStr
'ERROR ALWAYS OCCURS ON NEXT LINEon the next line
Cn.open CnStr
%>
<p>--</p>
<%
response.write "The End - ran ok"
%>
</body>
</html>
**** END CODE *****
? what to do?
? am I missing something 'obvious' out ?
Jim Bunton
If you are using windows authentication (also known as a
trusted connection) to connect, you don't supply a user
name, password in the connection string. Instead, you
indicate this by using Integrated Security=SSPI
in your connection string.
You also want to make sure the database is correct. In your
examples, you want to make sure you use Northwind (you have
Norwind listed).
You can find sample connection strings using the SQL Server
OLE DB provider at:
http://www.carlprothman.net/Default...erForSQLServer
-Sue
On Mon, 19 Sep 2005 11:44:58 GMT, "Jim Bunton"
<jBunton@.BlueYonder.co.uk> wrote:

>Win 2000, sqlServer 2000 Personal edition
>Trying ot connect using .asp Vb Script
>1. Sql server set to use Windows Authentication
>2. Log onto Windows 2000 as Jim Bunton {no password)
>3 Server 'Study' running ok
>4. sql query analyser
> i. "SELECT User_Name > dbo
> ii. [using database NorthWind]
> "SELECT * FROM Customers" > gives expected result
>5. VB script
>** BEGIN CODE connect.asp ***
><%
> @. LANGUAGE="VBSCRIPT"
>%>
><%
> Option explicit
> response.expires = 0
>%>
><!-- #include file="adovbs.inc" -->
><html>
><head>
><title></title>
></head>
><body>
><%
> dim Cn, CnStr
> Set Cn = Server.CreateObject("ADODB.Connection")
> Cn.ConnectionTimeOut = 1
> Cn.provider="sqloledb"
> response.write "Conn Provider is " & Cn.provider
> CnStr="Data Source=Study;Initial Catalog=Norhwind;User
>Id=sa;Password=;"
> ' Tried all sorts of user id's and paswords
> 'CnStr="Data Source=Study;Initial Catalog=Norhwind;User Id = 'Jim
>Bunton';Password=;"
> 'CnStr="Data Source=Study;Initial Catalog=Norhwind;User Id
>=dbo;Password=;"
> 'CnStr="Data Source=Study;Initial Catalog=Norhwind;User Id =
>JimBunton;Password=;"
> 'CnStr="Data Source='Study';Initial Catalogue='Norhwind';User Id
>='Study\Jim Bunton';Password=;"
>%>
><p>--</p>
><%
> response.write "Cnstr = " & CnStr
> 'ERROR ALWAYS OCCURS ON NEXT LINEon the next line
> Cn.open CnStr
>%>
><p>--</p>
><%
> response.write "The End - ran ok"
>%>
></body>
></html>
>**** END CODE *****
>? what to do?
>? am I missing something 'obvious' out ?
|||Thanks for your clear response Sue.
Unfortunately I still have a problem:
The following works:-
<%
dim Cn, SqlStr,rsCustomers
Set Cn=Server.CreateObject("ADODB.Connection")
Cn.Provider = "sqloledb"
Cn.Properties("Data Source") = "Study\StudySQLServer"
Cn.Properties("Initial Catalog") = "NorthWind"
Cn.Properties("Connect Timeout") = "3"
Cn.Properties("User ID") = "sa"
Cn.Properties("Password") = "mypassword"
Cn.open
. . . code which displays Customer info
The folowing does NOT:-
<%
dim Cn, CnStr, SqlStr,rsCustomers
Set Cn=Server.CreateObject("ADODB.Connection")
CnStr="Provider=sqloledb;" & _
"Data Source=Study\StudySqlServer;" & _
"Initial Catalog=NorthWind;" & _
"Integrated Security=SSPI"
response.write "cnStr = " & cnStr
' response.end
Cn.open CnStr
It fails at Cn.open CnStr
Error Type:
(0x80040E4D)
/MyWebs/Connect_wAuth.asp, line 15
response.write "cnStr = " & cnStr gives:-
cnStr = Provider=sqloledb;Data Source=Study\StudySqlServer;Initial Catalog=NorthWind;Integrated Security=SSPI
In Query Analyser (login using Windows Authentification)
select user_Name() >> dbo
select * from Customers >> a list of customers
"Sue Hoegemeier" <Sue_H@.nomail.please> wrote in message news:5tuui1l8ku9a5fl6r704knccn7jfun1kf4@.4ax.com...
> If you are using windows authentication (also known as a
> trusted connection) to connect, you don't supply a user
> name, password in the connection string. Instead, you
> indicate this by using Integrated Security=SSPI
> in your connection string.
> You also want to make sure the database is correct. In your
> examples, you want to make sure you use Northwind (you have
> Norwind listed).
> You can find sample connection strings using the SQL Server
> OLE DB provider at:
> http://www.carlprothman.net/Default...erForSQLServer
> -Sue
> On Mon, 19 Sep 2005 11:44:58 GMT, "Jim Bunton"
> <jBunton@.BlueYonder.co.uk> wrote:
>
|||Then it's likely the authentication settings on the IIS side
of it. Try adding the IUSR account as a login in SQL Server
with the appropriate permissions as needed for your code.
Also, turned on failed login audits in SQL Server and
restart the instance. That will help you track down what
login is failing.
-Sue
On Tue, 20 Sep 2005 10:17:50 GMT, "Jim Bunton"
<jBunton@.BlueYonder.co.uk> wrote:
[vbcol=seagreen]
>Thanks for your clear response Sue.
>Unfortunately I still have a problem:
>The following works:-
><%
>dim Cn, SqlStr,rsCustomers
> Set Cn=Server.CreateObject("ADODB.Connection")
> Cn.Provider = "sqloledb"
> Cn.Properties("Data Source") = "Study\StudySQLServer"
> Cn.Properties("Initial Catalog") = "NorthWind"
> Cn.Properties("Connect Timeout") = "3"
> Cn.Properties("User ID") = "sa"
> Cn.Properties("Password") = "mypassword"
> Cn.open
> . . . code which displays Customer info
>The folowing does NOT:-
><%
>dim Cn, CnStr, SqlStr,rsCustomers
> Set Cn=Server.CreateObject("ADODB.Connection")
> CnStr="Provider=sqloledb;" & _
> "Data Source=Study\StudySqlServer;" & _
> "Initial Catalog=NorthWind;" & _
> "Integrated Security=SSPI"
> response.write "cnStr = " & cnStr
> ' response.end
> Cn.open CnStr
>It fails at Cn.open CnStr
>Error Type:
>(0x80040E4D)
>/MyWebs/Connect_wAuth.asp, line 15
>response.write "cnStr = " & cnStr gives:-
>cnStr = Provider=sqloledb;Data Source=Study\StudySqlServer;Initial Catalog=NorthWind;Integrated Security=SSPI
>In Query Analyser (login using Windows Authentification)
>select user_Name() >> dbo
>select * from Customers >> a list of customers
>
>"Sue Hoegemeier" <Sue_H@.nomail.please> wrote in message news:5tuui1l8ku9a5fl6r704knccn7jfun1kf4@.4ax.com...

No comments:

Post a Comment