Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > SQL connection works in forms application, but not asp.net

Reply
Thread Tools

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

 
 
=?Utf-8?B?VGltIFp5Y2g=?=
Guest
Posts: n/a
 
      11-22-2005
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.

 
Reply With Quote
 
 
 
 
Bruce Barker
Guest
Posts: n/a
 
      11-22-2005
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)

"Tim Zych" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>



 
Reply With Quote
 
 
 
 
Rob Meade
Guest
Posts: n/a
 
      11-22-2005
"Tim Zych" wrote ...

> 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


 
Reply With Quote
 
=?Utf-8?B?VGltIFp5Y2g=?=
Guest
Posts: n/a
 
      11-22-2005
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

"Bruce Barker" wrote:

> 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)
>
> "Tim Zych" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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.
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?VGltIFp5Y2g=?=
Guest
Posts: n/a
 
      11-22-2005
I'm using Forms Authtication to log in.

"Rob Meade" wrote:

> "Tim Zych" wrote ...
>
> > 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
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
no wireless connection icon, but connection works =?Utf-8?B?Sm9objk2MDg=?= Wireless Networking 3 05-09-2006 07:31 PM
SQL connection works in forms application, but not asp.net_ Tim Zych ASP .Net 2 11-23-2005 02:39 PM
SQL connection works in forms application, but not asp.net Tim Zych ASP .Net 0 11-23-2005 07:55 AM
SQL Server connection string works with IIS 5.1 but not IIS 6 in ASP.NET John Kennedy ASP .Net Web Services 5 08-14-2003 12:15 AM
SQL Server connection string works with IIS 5.1 but not IIS 6 in ASP.NET John Kennedy ASP .Net Security 5 08-14-2003 12:15 AM



Advertisments