SQL connection works in forms application, but not asp.net

G

Guest

This function works in a Windows Forms .Net application, but when I try it in
an ASP.Net application, I get an error:

Cannot open database "codelib" requested by the login. The login failed.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Cannot open database
"codelib" requested by the login. The login failed.

Function SqlTest() As String
Dim cn As New OleDbConnection
Dim cmd As New OleDbCommand
Dim strConn As String
Dim strSql As String
strConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;Initial Catalog=codelib;Data
Source=X3934834392\SQLEXPRESS;Use Procedure for Prepare=1;Auto
Translate=True;Packet Size=4096;Workstation ID=X3934834392;Use Encryption for
Data=False;Tag with column collation when possible=False"
cn.ConnectionString = strConn
cn.Open()
strSql = "SELECT tblCode.title FROM tblCode WHERE tblCode.ID=" & 1 &
";"
cmd = New OleDbCommand(strSql, cn)
Return CStr(cmd.ExecuteScalar)
End Function


Does anybody know what I'm doing wrong or not doing?

Thanks.
 
B

Bruce Barker

you connect string says to use trusted secuity. this means the asp.net
application must run as a domain user with access to the database. in
server2003, config the app pool, else the impersonate in the web config

-- bruce (sqlwork.com)
 
R

Rob Meade

...
Does anybody know what I'm doing wrong or not doing?

A wild stab in the dark would perhaps be that maybe the website is using the
IUSR_<computer-name> account for browsing, and as such does not carry with
it any NT name used to log in to your database?

Only a guess...

Rob
 
G

Guest

I'm using Forms Authentication, if that matters.

I don't know how to implement any changes you mention. I'm using Windows 2000.

thanks
 
G

Guest

I'm using Forms Authtication to log in.

Rob Meade said:
...


A wild stab in the dark would perhaps be that maybe the website is using the
IUSR_<computer-name> account for browsing, and as such does not carry with
it any NT name used to log in to your database?

Only a guess...

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top