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

OLEDB database connection from ASP.NET

I can connect to a Sybase database from a WindowsApp project without
any problems, but when I use the same code to connect from an aspx.vb
file I get an OLEDB exception "Database server not found".

Code is:

Imports System.Data.OleDb

Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim strConn As String
Dim objDBConn As OleDbConnection
Dim objCommand As OleDbCommand

strConn = "provider=ASAProv;data source=systemsupport"

objDBConn = New OleDbConnection(strConn)
objCommand = New OleDbCommand("spEventLog_Add_2",
objDBConn)
objCommand.CommandType = CommandType.StoredProcedure

objDBConn.Open()
.................
If I paste this code into WindowsApp form it runs fine!

Is there something inherently different in the way I should connect to
the database in ASP.

I have the same problem when I call method functions in components
from the ASP that simply return arraylists - they work fine when
called from Windows apps but not when called from the ASP.

Tx,
Louise
Nov 18 '05 #1
2 1534
ASP.NET applications run under the user account ASPNET by default.
I'd say the likely problem is that this user account does not have
permissions to your database.
Either give it permissions or user impersonation to run ASP.NET under a
different user account that has the necessary privileges.
Here's more info:
http://msdn.microsoft.com/library/de...ersonation.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Louise Hadley" <lo***********@hadleybain.com> wrote in message
news:28**************************@posting.google.c om...
I can connect to a Sybase database from a WindowsApp project without
any problems, but when I use the same code to connect from an aspx.vb
file I get an OLEDB exception "Database server not found".

Code is:

Imports System.Data.OleDb

Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim strConn As String
Dim objDBConn As OleDbConnection
Dim objCommand As OleDbCommand

strConn = "provider=ASAProv;data source=systemsupport"

objDBConn = New OleDbConnection(strConn)
objCommand = New OleDbCommand("spEventLog_Add_2",
objDBConn)
objCommand.CommandType = CommandType.StoredProcedure

objDBConn.Open()
.................
If I paste this code into WindowsApp form it runs fine!

Is there something inherently different in the way I should connect to
the database in ASP.

I have the same problem when I call method functions in components
from the ASP that simply return arraylists - they work fine when
called from Windows apps but not when called from the ASP.

Tx,
Louise

Nov 18 '05 #2

Thanks very much Steve, I set up a user ASPNET in my database, and the
connection string "provider=ASAProv;data
source=systemsupport;uid=ASPNET" works!

Phew, now I can relax a bit over the weekend - was starting to pull my
hair out!

Louise
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

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

Similar topics

3
by: Chris Thunell | last post by:
I have a program where i connect to an access database and get some information out of it. I'm using the oledb.3.51 version, my computer doesn't seem to have the 4.0 version, but the computer that...
9
by: Pam Ammond | last post by:
I need the code to update the database when Save is clicked and a text field has changed. This should be very easy since I used Microsoft's wizards for the OleDBAdapter and OleDBConnection, and...
1
by: Brian | last post by:
It's still not working - is still looking for the Database in the same folder as the photo just added. But i've realised something... bear with me here! :) The basics of the way my photo album...
3
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I...
2
by: Martin | last post by:
Hi, I currently have an application that connects to an MS ACCESS database. This application uses an OLEDB connection string for MS ACCESS. Now, I'd like to upsize the application so I converted...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
3
by: blue875 | last post by:
When I run this connection, I get a security error. String connectStr = @"Provider=Microsoft.Jet.OLEDB.4.0;" + @"User Id=USER; Password=PASS;" + @"Data Source=\\SERVER\DIRECTORY\Data.mdb;" +...
2
by: Hetal | last post by:
Hi... I am a newbie VB.NET developer and i am looking at working with ADO.NET rather than ADO. In one of our native VB application with ADO, we used to create 1 connection object and that would...
0
by: Randy | last post by:
Hi,all I met a strange problem, I connected to access database using oledb connection, connection string like "Provider=Microsoft.Jet.OLEDB.4.0; Data...
1
by: ErikJL | last post by:
I have a simple webservice that performs a SELECT query against a database, and then an INSERT statement on the same database/table. The problem arises at the time when we create the second OleDB...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.