Z
ZenRhapsody
BACKGROUND INFO:
I'm using the common DbConnection object in my application because the user
can have data hosted in Excel, Access, SQL Server, or Oracle. I'm using the
common DbProviderFactories.GetFactory(providerName);
to get the appropriate factory object for creating a specific connection
object.
All well and good.
So my problem comes in when trying to write queries that have dates in the
where clause. Using JET for Excel and Access, I have to write something
like "WHERE dte > #5/15/2006#" while in SQL Server it's "WHERE dte >
'05/15/2006' "
(I know regional settings for cultures are important, and am planning to
handle them)
MY QUESTION IS THIS:
Anyone have any good guidance on how to decide at runtime which format to
use? Or is there any format that works for all database providers? I have
a variable set for format which I am currently setting when the connection
string is used to build the connection. This code selects XLS, MDB, or SQL.
But, if a user specifies something else for 'providerName' that works on his
machine (let's say some new database vendor writes a NET 2.0 data provider
that I don't have), I won't know how to handle that.
I'm using the common DbConnection object in my application because the user
can have data hosted in Excel, Access, SQL Server, or Oracle. I'm using the
common DbProviderFactories.GetFactory(providerName);
to get the appropriate factory object for creating a specific connection
object.
All well and good.
So my problem comes in when trying to write queries that have dates in the
where clause. Using JET for Excel and Access, I have to write something
like "WHERE dte > #5/15/2006#" while in SQL Server it's "WHERE dte >
'05/15/2006' "
(I know regional settings for cultures are important, and am planning to
handle them)
MY QUESTION IS THIS:
Anyone have any good guidance on how to decide at runtime which format to
use? Or is there any format that works for all database providers? I have
a variable set for format which I am currently setting when the connection
string is used to build the connection. This code selects XLS, MDB, or SQL.
But, if a user specifies something else for 'providerName' that works on his
machine (let's say some new database vendor writes a NET 2.0 data provider
that I don't have), I won't know how to handle that.