OLEDB database connection from ASP.NET

Discussion in 'ASP .Net' started by Louise Hadley, Apr 16, 2004.

  1. 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
    Louise Hadley, Apr 16, 2004
    #1
    1. Advertising

  2. 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/d...-us/cpguide/html/cpconaspnetimpersonation.asp

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net


    "Louise Hadley" <> wrote in message
    news:...
    > 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
    Steve C. Orr [MVP, MCSD], Apr 16, 2004
    #2
    1. Advertising

  3. 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!
    Louise Hadley, Apr 17, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Giuseppe D'Elia

    Error with ASP.NET opening OleDb/ODBC database

    Giuseppe D'Elia, Jul 15, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    1,413
    John Toop
    Jul 25, 2003
  2. Mathew Vording

    asp.net ms-access oledb connection open error

    Mathew Vording, Aug 15, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    1,153
    Mathew Vording
    Aug 15, 2003
  3. =?Utf-8?B?Uk1M?=

    MS Access OLEDB connection problem

    =?Utf-8?B?Uk1M?=, Jul 21, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    3,244
    =?Utf-8?B?Uk1M?=
    Jul 24, 2004
  4. Replies:
    0
    Views:
    601
  5. Randy
    Replies:
    0
    Views:
    379
    Randy
    May 14, 2007
Loading...

Share This Page