PDA

View Full Version : I can't connect my ASP page with MSSQL


Grammarian-Bot
Jul 7, 2006, 12:08 PM
This is what my connect.asp looks like.



<Html>
<Head>
<Title> Testing Our Connection </Title>
</Head>
<Body>
<%
Dim adOpenForwardOnly, adLockReadOnly, adCmdTable
adOpenForwardOnly=0
adLockReadOnly=1
adCmdTable=2

Dim objConn, objRS
Set objConn = Server.CreateObject("ADODB.CONNECTION")
Set objRS = Server.CreateObject("ADODB.RECORDSET")

Dim strDatabaseType
strDatabaseType = "MSDE"

objConn.Open "Driver={SQL Server};" & _
"Server=127.0.0.1;" & _
"Database=payroll;" & _
"Uid=;" & _
"Pwd=;"


objRS.Open "payroll", objConn, adOpenForwardOnly,adLockReadOnly, adCmdTable

While not objrs.eof
rsponse.write objrs.fields("emp_id") & "<br>"
objrs.movenext
Wend

objrs.Close
Set objrs = Nothing

objconn.Close
Set objconn = Nothing
%>
</body>
</html>


But when I open it in my IE I get the following Error Message.





Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E4D)
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'ADMINISTRATOR\IUSR_FAHAD'.
/begasp/connect.asp, line 22

Line 22 is the connection string line on my editor.

Please can someone telll me how can I fix this problem.

LTheobald
Jul 10, 2006, 12:50 AM
Has the username in the error message been given rights to access the database? That's what the error message is saying - the user doesn't have access to the db

yesh kumar
Aug 7, 2008, 11:56 PM
You should pass the Userid and Password details in UID and PWD. Now it is taking the Windows authentication to connect to SQL where it is getting failed.