Re: Can you use the OleDb classes for SQL Server?
- From: Gustaf <gustafl@xxxxxxxxxx>
- Date: Thu, 05 Jul 2007 18:23:24 +0200
Milosz Skalecki [MCAD] wrote:
Yes you can. OleDb is the old style way of abstracting database providers. The best way of doing abstraction is using stored procedures, as you can delegate sql queries to database, otherwise you end up with different version of queries for different RDBMSes.
I agree that it would be neat to just call a stored procedure for the INSERT method I need. But a stored procedure I write for SQL Server can't be moved directly to Oracle, can it? I know nothing about stored procedures in Oracle. So I think I need to put the INSERT statment in the C# code, or possibly in a config file.
In addition, if you use .NET 2.0, it offers another way od specialization for different RDBMS via providers and factories:
http://www.simple-talk.com/dotnet/.net-framework/ado.net-2.0-factory-classes/
That's a good article. I was able to make use of the System.Data.SqlClient provider, but the OleDb provider did not work. When opening the connection, I get the useless error (type OleDbException):
No error message available, result code: DB_E_ERRORSOCCURRED(0x80040E21).
The app.config file currently looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="provider" value="System.Data.OleDb"/>
<add key="connectionString" value="Provider=SQLOLEDB;Data Source=.;Initial
Catalog=MyCompany;Integrated Security=true;User Instance=True"/>
</appSettings>
</configuration>
The solution would still be very useful, if I can just change "System.Data.SqlClient" to "System.Data.OracleClient" at deployment.
Gustaf
.
- Follow-Ups:
- Re: Can you use the OleDb classes for SQL Server?
- From: William \(Bill\) Vaughn
- Re: Can you use the OleDb classes for SQL Server?
- References:
- Can you use the OleDb classes for SQL Server?
- From: Gustaf
- Can you use the OleDb classes for SQL Server?
- Prev by Date: DataGridView and saving info
- Next by Date: Re: Can you use the OleDb classes for SQL Server?
- Previous by thread: Re: Can you use the OleDb classes for SQL Server?
- Next by thread: Re: Can you use the OleDb classes for SQL Server?
- Index(es):