Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connect to sql(MSDE) database error

Status
Not open for further replies.

920506

Programmer
Jun 13, 2003
201
0
0
US
Hi,all
In my ODBC setup for SQL server, I used windows authentication. after set up, the test for datasource connection is successful.

In my ASP code, I used
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "dsn=CMC;Trusted_Connection=""sspi"""
it doesn't work, it always come up with error message.

Microsoft OLE DB Provider for ODBC Drivers (0x80040E4D)
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'BETTYPC\IUSR_BETTYPC'.
/myweb/webmsde/init.asp, line 30

even I changed to
conn.Open "Driver={SQL Server};Server=BETTYPC;Database=CMC;Truested_Connection=Yes"

it still give me the same error message.
Anybody can help, please?
Betty
 
Try something like this:

For Standard Security

oConn.Open "Driver={SQL Server};" & _
"Server=MyServerName;" & _
"Database=myDatabaseName;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

For Trusted Connection security

oConn.Open "Driver={SQL Server};" & _
"Server=MyServerName;" & _
"Database=myDatabaseName;" & _
"Uid=;" & _
"Pwd="
' Or
oConn.Open "Driver={SQL Server};" & _
"Server=MyServerName;" & _
"Database=myDatabaseName;" & _
"Trusted_Connection=yes"

taken from the link

hope this helps you

-VJ
 
amorous,
I believe I used:conn.Open "Driver={SQL Server};Server=BETTYPC;Database=CMC;Truested_Connection=Yes"

which is the exactly same as you suggested:
oConn.Open "Driver={SQL Server};" & _
"Server=MyServerName;" & _
"Database=myDatabaseName;" & _
"Trusted_Connection=yes"

If my windows login username is Betty, do I need to
run command in query analyzer:
sp_addlogin 'Betty', 'password'
in order for ASP user database? anything else like IIS setup I need to do??
Thanks
Betty
 
Connecting IIS to a SQL Server (MSDE) requires that the anonymous IUSR account be granted access to the database\tables. This is easily performed using SQL Server enterprise manager.

sp_addlogin will create a user/password for a SQL Server using SQL Server Authentication.

When you use the "trusted=Yes" part of a connection string you are using windows authentication.

If you do not have EM you will be adding this user to your SQL server using sp_grantdbaccess. Check out Sql Server Books Online for the syntax.
 
hi, mike,
thanks for your valuable posting. I used EM and your suggestion,I added login 'BETTY\IUSER_BETTYPC' and grant access to default to CMC database, now it doesn't complain with that message anymore.

but first I tried to use the following command, it doesn't work in query analyzer.
I typed
use master
sp_addlogin 'BETTY\IUSER_BETTYPC'
go
--it complain, '\' is not a valid character.
the I typed
use CMC --database name
sp_grantdbaccess 'IUSER_BETTYPC'
go
thanks
Betty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top