473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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

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.

Nov 23 '05 #1
4 2294
"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
Nov 23 '05 #2
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" <Ti*****@discussions.microsoft.com> wrote in message
news:E1**********************************@microsof t.com...
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.

Nov 23 '05 #3
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" <Ti*****@discussions.microsoft.com> wrote in message
news:E1**********************************@microsof t.com...
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.


Nov 23 '05 #4
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

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dmitry Karneyev | last post by:
Hi All! I've got an ado.net app with several win forms. In the first form (form1) I connect to DB and in other forms I use connection string generated by the form1 and stored in sqlconnection...
10
by: Brian Conway | last post by:
I have no idea what is going on. I have a Login screen where someone types in their login information and this populates a datagrid based off of the login. Works great in debug and test through...
4
by: refer_to_website | last post by:
How can I use the Server.MapPath(".") value inside of the web.config? For example, when I add the following just before the </configuration>, and run via CTRL-F5, I receive error The '&'...
1
by: toke | last post by:
I've build a DLL in VB.net that handles all sorts of business logic. This DLL accecesses a SQL server for some data in the following way: <Begin pseudo-code snip> Open a Connection Con = new...
26
by: Rajeev Tipnis | last post by:
http://support.microsoft.com/default.aspx?scid=kb;en- us;819450 Questions: 1) Is this patch (fix) applicable to the .NET 1.1 Framework as well? That is, if we have Framework 1.1 (On...
0
by: Tim Zych | last post by:
I'm trying to connect to a SQL Server (Express) database with an Asp.Net solution that currently uses MS Access. I want to replace it with SQL Server. I got a rudimentary prototope to work in a...
2
by: Tim Zych | last post by:
I'm trying to connect to a SQL Server (Express) database with an Asp.Net solution that currently uses MS Access. I want to replace it with SQL Server. I got a rudimentary prototope to work in a...
8
by: Greg Strong | last post by:
Hello All, The short questions are 1 Do you know how to make DSN connection close in Access to Oracle 10g Express Edition? &/or 2 Do you know how to make a DSN-less pass-through query...
8
by: Merk | last post by:
I'm looking for a safe and maintainable way to store connection string info (connecting to SQL Server 2005 from .NET 2.0 Windows Forms client app); things like server name or IP address and...
20
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.