Connecting to an Oracle database from a winforms app.

Apr 20, 2011 at 7:00 AM

Hi Jeremy,

I've been successfully using Picasso with a web app. (with an Oracle back-end) for a while now, but I can't see how to do the same with a winforms app.  In the front-end application I've set 2 app. variables for "Driver" and "ConnectionString".  The ConnectionString is "Data Source=CPDEV;Persist Security Info=True;User ID=<username>;Password=<password>;Pooling=True;Min Pool Size=5;Max Pool Size=10;Incr Pool Size=5;Decr Pool Size=5;Connection Lifetime=120".  But the app. keeps trying to do the default SQLServer connection.  What am I doing wrong?

Thanks

Tony.

 

Coordinator
Apr 20, 2011 at 2:43 PM

Hello Tony,

The configuration is quite simple, exactly the same as web, and should just work. I regularly use the framework in a variety of project types other than web projects, and it usually works fine.

I would suggest that first you check that you are using an app.config file that the project knows about, and verify that it is being copied into the bin directory as {appname}.exe.config (the mechanics are slightly different than a web.config). I would also check that the xml is correctly formed, and that config settings are in general being read correctly. Finally, if none of that works, then using the lastest version of the Framework source code (it’s a stable codebase but best to check/update), you should use the debugger to step into CDataSrc.Default, to find out what settings are being encountered in the config file, and why it is not reading/interpreting the settings correctly – it’s pretty much just a simple case statement.

There is one particular option that is supported, where an appSetting called “ActiveConnectionString” lets you name a connection that resides in the standard <ConnectionStrings section. This collection sometimes includes default/automatic sqlserver connections for some Microsoft components. So it’s possible that if no settings at all were picked up in the config file, then it might fall thru to this case, which would fit the situation that you describe. This would imply badly formed xml like a typo in the config file, or something like that, preventing any config settings from working.

If you are in a hurry, a quick workaround is to explicitly set the default datasrc object during application startup (CDataSrc.Default is the static global variable that gets used as the default connection string), by constructing a specific type of driver class like COracleMS with a connection string parameter. Then you can figure out later why the appSettings weren’t being read properly.

Jeremy

From: tleeming [email removed]
Sent: Wednesday, April 20, 2011 7:00 PM
To: postage@ihug.co.nz
Subject: Connecting to an Oracle database from a winforms app. [Picasso:254609]

From: tleeming

Hi Jeremy,

I've been successfully using Picasso with a web app. (with an Oracle back-end) for a while now, but I can't see how to do the same with a winforms app. In the front-end application I've set 2 app. variables for "Driver" and "ConnectionString". The ConnectionString is "Data Source=CPDEV;Persist Security Info=True;User ID=<username>;Password=<password>;Pooling=True;Min Pool Size=5;Max Pool Size=10;Incr Pool Size=5;Decr Pool Size=5;Connection Lifetime=120". But the app. keeps trying to do the default SQLServer connection. What am I doing wrong?

Thanks

Tony.


No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1209 / Virus Database: 1500/3584 - Release Date: 04/19/11