473,396 Members | 1,792 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,396 software developers and data experts.

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

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 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.
-----

Here's the function. I pulled the connection string out of the data
connection that Visual Studio.Net created when I added a new connection. I
do not know if this is the proper connection string. It worked for the Forms
app, but I do not know what must be done to get it to work for Asp.Net.

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

Is there a tutorial that can walk me through step by step how to connect to
SQL Server via ASP.Net? Or can someone please help me to get this to work?
This is an ASP.Net application that uses simple Forms authentication.

thanks for any help.

This is a 2nd post based on an earlier post. I got some replies that look
like they pointed in a direction in a macro way, but I do not know how to
implement them.


Nov 23 '05 #1
2 942
In your connectionstring i do not see the userid and password attribute
-------
Regards ,
C#, VB.NET , SQL SERVER , UML , DESIGN Patterns Interview question book
http://www.geocities.com/dotnetinterviews/
My Interview Blog
http://spaces.msn.com/members/dotnetinterviews/

Nov 23 '05 #2
It's the same connection string that worked for the windows forms.

I tried entering the password and userid, which actually I don't have one
because SQL Server is using Windows Authentication, and got the same error.
<sh**********@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
In your connectionstring i do not see the userid and password attribute
-------
Regards ,
C#, VB.NET , SQL SERVER , UML , DESIGN Patterns Interview question book
http://www.geocities.com/dotnetinterviews/
My Interview Blog
http://spaces.msn.com/members/dotnetinterviews/

Nov 23 '05 #3

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...
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
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
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
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,...
0
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...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.