Re: Select statement for boolean and/or DateTime values?




"Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx> wrote in message news:uRfU%23XwEIHA.4028@xxxxxxxxxxxxxxxxxxxxxxx
Olaf Krause wrote:
Hi together,
....
microsoft.public.dotnet.framework.adonet.

Oops you're right, did not pay enough attention on the net behind the ado



It does?? SQL Server does not have a boolean datatype, and even if it did, you cannot compare a boolean with a string?? Are you sure "booleancolumn" isn't actually a varchar column?

yepp it works, and the column is boolean or to be more precise bit. I doublechecked this using directly the SQLQuery tool within the SQL Server Management Studio.

The closest SQL Server has to a boolean
datatype is the bit datatype, which holds 0,1 or Null. If you utilize parameters, ADO.Net will translate a boolean value into either 0 or 1.
You should also use a standard datetime format, such as ISO: yyyymmdd hh:nn:ss will always work, at least in SQL Server. But again, utilizing parameters will relieve you of the necessity of worrying about date formats.

OK, currently I'm rewriting my code to use parameters instead of directly setting the values as strings.

. But for the rest the select statement seems not to work
as expected.

Access (Jet) DOES have a boolean datatype, but, it requires a nonstandard date format: either US (mm/dd/yyyy) or tyyyy-mm-dd.

You are right, that's what I also found out

Again, if you utilize parameters, values will be passed correctly to the Jet engine
....

No, there will be differences in SQL dialectst depending on the database. However, utilizing parameters will help.

==>

I think something like
string command= "SELECT * FROM mytable WHERE datetimecolumn= @datetimecolumn";
IDbCommand cmd=AdoProviderFactory.GetCommand(command,m_DB.Connection,m_DB.ProviderType);
cmd.Parameters.Add(new xyzDbParameter("@datetimecolumn", xyzDbType.Date)).Value = New DateTime("20.10.2007 10:43:25");
IDataReader reader = cmd.ExecuteReader();
....
should do it

thx for you comments

.



Relevant Pages

  • Re: Unable to Locate Server
    ... When connecting to SQL Server 2005, ... >>> encrypt, Boolean trustServerCert, Boolean integratedSecurity, ... >>> owningObject, SqlConnectionString connectionOptions, String newPassword, ...
    (microsoft.public.sqlserver.setup)
  • Re: Custom membership provider problem
    ... SQL server 2005 does not install with the TCP/IP protocol turned on. ... >An error has occurred while establishing a connection to the server. ... 25 - Connection string is not valid) ... >Boolean& failoverDemandDone, String host, String failoverPartner, String ...
    (microsoft.public.dotnet.framework.aspnet)
  • Connecting to Sharepoint Problem
    ... String bstrCurrentFolderUrl, Boolean& pbCanCustomizePages, Boolean& ... pVerGhostedSetupPath, UInt32& pdwPartCount, Object& pvarMetaData, ... pbstrRedirectUrl, Boolean& pbObjectIsList, Guid& pgListId, UInt32& ...
    (microsoft.public.biztalk.general)
  • Re: Connecting to Sharepoint Problem
    ... String bstrCurrentFolderUrl, Boolean& pbCanCustomizePages, Boolean& ... pVerGhostedSetupPath, UInt32& pdwPartCount, Object& pvarMetaData, ... pbstrRedirectUrl, Boolean& pbObjectIsList, Guid& pgListId, UInt32& ...
    (microsoft.public.biztalk.general)
  • RE: installation WSS 3.0
    ... <exception, Boolean breakConnection) ... <owningObject, SqlConnectionString connectionOptions, String newPassword, ... <newDatabaseId, String strDatabaseServer, String strDatabaseName, String ... <databaseServer, String databaseName, String databaseUsername, String ...
    (microsoft.public.windows.server.sbs)