473,652 Members | 3,045 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Ole Db.OleDbExcepti on: 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=SQLOL EDB.1;Integrate d Security=SSPI;P ersist
Security Info=False;Init ial Catalog=codelib ;Data
Source=X3934834 392\SQLEXPRESS; Use Procedure for Prepare=1;Auto
Translate=True; Packet Size=4096;Works tation ID=X3934834392; Use Encryption for
Data=False;Tag with column collation when possible=False"
cn.ConnectionSt ring = strConn
cn.Open()
strSql = "SELECT tblCode.title FROM tblCode WHERE tblCode.ID=" & 1 &
";"
cmd = New OleDbCommand(st rSql, cn)
Return CStr(cmd.Execut eScalar)
End Function
Does anybody know what I'm doing wrong or not doing?

Thanks.

Nov 23 '05 #1
4 2310
"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*****@discus sions.microsoft .com> wrote in message
news:E1******** *************** ***********@mic rosoft.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.Ole Db.OleDbExcepti on: 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=SQLOL EDB.1;Integrate d Security=SSPI;P ersist
Security Info=False;Init ial Catalog=codelib ;Data
Source=X3934834 392\SQLEXPRESS; Use Procedure for Prepare=1;Auto
Translate=True; Packet Size=4096;Works tation ID=X3934834392; Use Encryption
for
Data=False;Tag with column collation when possible=False"
cn.ConnectionSt ring = strConn
cn.Open()
strSql = "SELECT tblCode.title FROM tblCode WHERE tblCode.ID=" & 1
&
";"
cmd = New OleDbCommand(st rSql, cn)
Return CStr(cmd.Execut eScalar)
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*****@discus sions.microsoft .com> wrote in message
news:E1******** *************** ***********@mic rosoft.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.Ole Db.OleDbExcepti on: 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=SQLOL EDB.1;Integrate d Security=SSPI;P ersist
Security Info=False;Init ial Catalog=codelib ;Data
Source=X3934834 392\SQLEXPRESS; Use Procedure for Prepare=1;Auto
Translate=True; Packet Size=4096;Works tation ID=X3934834392; Use Encryption
for
Data=False;Tag with column collation when possible=False"
cn.ConnectionSt ring = strConn
cn.Open()
strSql = "SELECT tblCode.title FROM tblCode WHERE tblCode.ID=" & 1
&
";"
cmd = New OleDbCommand(st rSql, cn)
Return CStr(cmd.Execut eScalar)
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
3301
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 object of form1. If I use windows authorization of SQL Server everything works fine, but when I use SQL Server authorization it doesn't work because sqlconnection object doesn't store the password and as a result of retrieving connection string...
10
2703
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 VS, however, when I change to release and put it out on the web it fails giving me the following error message The underlying connection was closed. Could not establish a trust relationship with the remote server.
4
17650
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 '&' character, hexadecimal value 0x26, cannot begin with a name. <appSettings> <add key="ConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(".") & "DATABASE\test.mdb;" />
1
1205
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 Connection (bla bla bla arguments) 'Make recordset 1 (using stored procedures, but only containing "select" commands) rs1 = new recordset
26
16499
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 Win2K3/IIS6.0), do we still need this patch? 2) Does it specifically solve only this error: The underlying connection was closed. An unexpected error
0
249
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 .Net Forms application, but when I try to connect to the database from ASP.Net, I get an error: ----- Cannot open database "codelib" requested by the login. The login failed. Description: An unhandled exception occurred during the execution of...
2
950
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 .Net Forms application, but when I try to connect to the database from ASP.Net, I get an error: ----- Cannot open database "codelib" requested by the login. The login failed. Description: An unhandled exception occurred during the execution of...
8
9628
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 work from
8
2553
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 database name. I need to provide the client application with this info for connecting to both a test SQL Server and a production server. I would prefer to NOT hard-code this info into the client application, and App.Config seems rather unsafe as the...
20
3269
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 many connection has been used ? 2. If the maximum pool size has been reached, what happens when I call the method Open to open the connection ? Will I get an error ? MSDN says the request is queued, but will I get an error in the open method ? ...
0
8367
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8811
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8703
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8467
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7302
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2703
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.