OleDB connection.Open() fails in WebService only

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ErikJL
    New Member
    • Jul 2008
    • 1

    OleDB connection.Open() fails in WebService only

    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 connection object and attempt to Open() it. The connection string is exactly the same for both connection objects. Another intersting thing is that this code works fine when it is used in a Windows Form project.

    The code snippet:
    Code:
       
    try
    {
    // Connect to database
    // Initialize a new OleDbConnection
    cnOleDBSDE = new OleDbConnection();
     
    // Setup the connection string 
    cnOleDBSDE.ConnectionString = "Data Provider=" +DBProvider+ ";"+
    "Provider=" + DBShapeProvider + ";" +
    "Data Source=" + DBName + ";" +
    "Pooling=" + Pooling.ToString() + ";" +
    "User Id=" + UserId + ";" +
    "Password=" + Password;
    // Open the connection
    cnOleDBSDE.Open();
    }
    Here is 'cnOleDBSDE' the first time around just before .Open() is called:
    Code:
     
    cnOleDBSDE
    {System.Data.OleDb.OleDbConnection}
    base {System.Data.Common.DbConnection}: {System.Data.OleDb.OleDbConnection}
    ConnectionString: "Data Provider=MSDAORA.1;Provider=MSDataShape;Data Source=sdeprod;Pooling=False;User Id=UID;Password=PASSWORD"
    ConnectionTimeout: 15
    Database: ""
    DataSource: "sdeprod"
    Provider: "MSDataShape"
    ServerVersion: 'cnOleDBSDE.ServerVersion' threw an exception of type 'System.InvalidOperationException'
    State: Closed
    And here is cnOleDBSDE the second time around (when it fails), just before .Open() is called:

    Code:
     cnOleDBSDE 
    {System.Data.OleDb.OleDbConnection}
    base {System.Data.Common.DbConnection}: {System.Data.OleDb.OleDbConnection}
    ConnectionString: "Data Provider=MSDAORA.1;Provider=MSDataShape;Data Source=sdeprod;Pooling=False;User Id=UID;Password=PASSWORD"
    ConnectionTimeout: 15
    Database: ""
    DataSource: "sdeprod"
    Provider: "MSDataShape"
    ServerVersion: 'cnOleDBSDE.ServerVersion' threw an exception of type 'System.InvalidOperationException'
    State: Closed
    I don't see any differences. Here is the exception that is thrown:

    ex
    {"Data provider could not be initialized."}
    [System.Data.Ole Db.OleDbExcepti on]: {"Data provider could not be initialized."}
    Data: {System.Collect ions.ListDictio naryInternal}
    HelpLink: null
    InnerException: null
    Message: "Data provider could not be initialized."
    Source: "MSDataShap e"
    StackTrace: " at System.Data.Ole Db.OleDbConnect ionInternal..ct or(OleDbConnect ionString constr, OleDbConnection connection)\r\n at System.Data.Ole Db.OleDbConnect ionFactory.Crea teConnection(Db ConnectionOptio ns options, Object poolGroupProvid erInfo, DbConnectionPoo l pool, DbConnection owningObject)\r \n at System.Data.Pro viderBase.DbCon nectionFactory. CreateNonPooled Connection(DbCo nnection owningConnectio n, DbConnectionPoo lGroup poolGroup)\r\n at System.Data.Pro viderBase.DbCon nectionFactory. GetConnection(D bConnection owningConnectio n)\r\n at System.Data.Pro viderBase.DbCon nectionClosed.O penConnection(D bConnection outerConnection , DbConnectionFac tory connectionFacto ry)\r\n at System.Data.Ole Db.OleDbConnect ion.Open()\r\n at GDAC.GDAC.OpenO leDbConnection( String DBName, String DBProvider, String DBShapeProvider , Boolean Pooling, String UserId, String Password) in D:\\ETS\\GDAC\\ GDAC.cs:line 471"
    TargetSite: {Void .ctor(System.Da ta.OleDb.OleDbC onnectionString , System.Data.Ole Db.OleDbConnect ion)}

    Any ideas?
    Last edited by Curtis Rutland; Jul 25 '08, 07:06 PM. Reason: Protecting your privacy -- removed account name and password
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    hmm. I don't think you can make a web service in ASP, and this doesn't look like VBScript. Perhaps you meant to post in the .NET forum? I'll move it over for you.

    Jared

    Comment

    Working...