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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP connecting to SQL Server issue

Status
Not open for further replies.

TonyKhela

Technical User
Joined
May 7, 2002
Messages
157
Location
GB
I am using some ASP code to access SQL databases . The connection code is as shown below but fails on the last
line with:
"Login failed for user 'abcd'."

I'm not sure why abcd's name appears (he's now left us). I'm logged in my PC as 'cdef' and when I write ASP code to query my logon, the result is "cdef", so how abcd's name arises, I don't know. This only happens with one of the databases; I can access another DB without problem using the same code.

Do I need to add anything else to the connection string for Windows NT authentication, or is there a permissions problem with the database?

the code:

Call OpenDIR()
Sub OpenDIR()
Set cnDIR =
Server.CreateObject("ADODB.Connection")

'Connection to SQL Server without using ODBC data source.

cnDIR.Provider = "sqloledb"
cnDIR.Open "Driver={SQL Server};Server=server1; Database=DB1"

End Sub

thx
TK
 
Could be there is another connection string somewhere in the application that specifies the user and password and since he is no longer there, it doesn't exist anymore?

We all know this sort of thing should be compartmentalized so that the whole application uses the same connection, but sometimes in the real world it doesn't actually happen that way. The very first thing I would do is search all the code for this guy's username.
 
No, nothing on the username elsewhere; but I've made some progress.

OK, so now with this code (see below) I get the following error:
Login failed for user '\'.

Is the ASP syntax correct or do I need a ; after SSPI?
--------------------------
Call OpenDIR()
Sub OpenDIR()
Set cnDIR = Server.CreateObject("ADODB.Connection")

'Connection to SQL Server

cnDIR.Provider ="sqloledb"
cnDIR.Open "Data Source=Server1; Initial Catalog=DB1; Integrated Security=SSPI"
End Sub
 
create a database user in SQL Enterprise Manager.
Grant access to Select, Insert, or whatever to DB1

If you are using a web page(aspx) create one for webbox\aspnet user, i ususally only give select access for that account.

If it is a different front end, grant domain\user select rights.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top