OLEDB database connection from ASP.NET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Louise Hadley

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

    Public Class WebForm1
    Inherits System.Web.UI.P age


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles MyBase.Load

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

    strConn = "provider=ASAPr ov;data source=systemsu pport"

    objDBConn = New OleDbConnection (strConn)
    objCommand = New OleDbCommand("s pEventLog_Add_2 ",
    objDBConn)
    objCommand.Comm andType = CommandType.Sto redProcedure

    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]

    #2
    Re: OLEDB database connection from ASP.NET

    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:


    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP



    "Louise Hadley" <louise.hadley@ hadleybain.com> wrote in message
    news:28d72892.0 404161234.6d00c acc@posting.goo gle.com...[color=blue]
    > 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.Ole Db
    >
    > Public Class WebForm1
    > Inherits System.Web.UI.P age
    >
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArg s) Handles MyBase.Load
    >
    > Dim strConn As String
    > Dim objDBConn As OleDbConnection
    > Dim objCommand As OleDbCommand
    >
    > strConn = "provider=ASAPr ov;data source=systemsu pport"
    >
    > objDBConn = New OleDbConnection (strConn)
    > objCommand = New OleDbCommand("s pEventLog_Add_2 ",
    > objDBConn)
    > objCommand.Comm andType = CommandType.Sto redProcedure
    >
    > 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[/color]


    Comment

    • Louise Hadley

      #3
      Re: OLEDB database connection from ASP.NET


      Thanks very much Steve, I set up a user ASPNET in my database, and the
      connection string "provider=ASAPr ov;data
      source=systemsu pport;uid=ASPNE T" 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!

      Comment

      Working...