473,382 Members | 1,362 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,382 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 1533
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.