By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,185 Members | 1,207 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,185 IT Pros & Developers. It's quick & easy.

OleDB connection.Open() fails in WebService only

P: 1
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:
Expand|Select|Wrap|Line Numbers
  2. try
  3. {
  4. // Connect to database
  5. // Initialize a new OleDbConnection
  6. cnOleDBSDE = new OleDbConnection();
  8. // Setup the connection string 
  9. cnOleDBSDE.ConnectionString = "Data Provider=" +DBProvider+ ";"+
  10. "Provider=" + DBShapeProvider + ";" +
  11. "Data Source=" + DBName + ";" +
  12. "Pooling=" + Pooling.ToString() + ";" +
  13. "User Id=" + UserId + ";" +
  14. "Password=" + Password;
  15. // Open the connection
  16. cnOleDBSDE.Open();
  17. }
Here is 'cnOleDBSDE' the first time around just before .Open() is called:
Expand|Select|Wrap|Line Numbers
  2. cnOleDBSDE
  3. {System.Data.OleDb.OleDbConnection}
  4. base {System.Data.Common.DbConnection}: {System.Data.OleDb.OleDbConnection}
  5. ConnectionString: "Data Provider=MSDAORA.1;Provider=MSDataShape;Data Source=sdeprod;Pooling=False;User Id=UID;Password=PASSWORD"
  6. ConnectionTimeout: 15
  7. Database: ""
  8. DataSource: "sdeprod"
  9. Provider: "MSDataShape"
  10. ServerVersion: 'cnOleDBSDE.ServerVersion' threw an exception of type 'System.InvalidOperationException'
  11. State: Closed
And here is cnOleDBSDE the second time around (when it fails), just before .Open() is called:

Expand|Select|Wrap|Line Numbers
  1.  cnOleDBSDE 
  2. {System.Data.OleDb.OleDbConnection}
  3. base {System.Data.Common.DbConnection}: {System.Data.OleDb.OleDbConnection}
  4. ConnectionString: "Data Provider=MSDAORA.1;Provider=MSDataShape;Data Source=sdeprod;Pooling=False;User Id=UID;Password=PASSWORD"
  5. ConnectionTimeout: 15
  6. Database: ""
  7. DataSource: "sdeprod"
  8. Provider: "MSDataShape"
  9. ServerVersion: 'cnOleDBSDE.ServerVersion' threw an exception of type 'System.InvalidOperationException'
  10. State: Closed
I don't see any differences. Here is the exception that is thrown:

{"Data provider could not be initialized."}
[System.Data.OleDb.OleDbException]: {"Data provider could not be initialized."}
Data: {System.Collections.ListDictionaryInternal}
HelpLink: null
InnerException: null
Message: "Data provider could not be initialized."
Source: "MSDataShape"
StackTrace: " at System.Data.OleDb.OleDbConnectionInternal..ctor(Ol eDbConnectionString constr, OleDbConnection connection)\r\n at System.Data.OleDb.OleDbConnectionFactory.CreateCon nection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)\r\n at System.Data.ProviderBase.DbConnectionFactory.Creat eNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)\r\n at System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection owningConnection)\r\n at System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)\r\n at System.Data.OleDb.OleDbConnection.Open()\r\n at GDAC.GDAC.OpenOleDbConnection(String DBName, String DBProvider, String DBShapeProvider, Boolean Pooling, String UserId, String Password) in D:\\ETS\\GDAC\\GDAC.cs:line 471"
TargetSite: {Void .ctor(System.Data.OleDb.OleDbConnectionString, System.Data.OleDb.OleDbConnection)}

Any ideas?
Jul 24 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 3,405
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.

Jul 25 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.