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:
Here is 'cnOleDBSDE' the first time around just before .Open() is called:
And here is cnOleDBSDE the second time around (when it fails), just before .Open() is called:
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?
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();
}
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
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
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?
Comment