PC Review


Reply
Thread Tools Rate Thread

Detecting database column data type of smalldatetime vs. datetime?

 
 
Jen
Guest
Posts: n/a
 
      7th Aug 2007
Is there a way for C# ADO.NET code to determine whether a SQL Server column
data type is smalldatetime vs. datetime? It looks like DataColumn.DataType
makes no distinction, both return DateTime.


 
Reply With Quote
 
 
 
 
Miha Markic
Guest
Posts: n/a
 
      7th Aug 2007
You should use SqlConnection.GetSchema method to retrieve these kind of
information.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Jen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is there a way for C# ADO.NET code to determine whether a SQL Server
> column data type is smalldatetime vs. datetime? It looks like
> DataColumn.DataType makes no distinction, both return DateTime.
>


 
Reply With Quote
 
Jen
Guest
Posts: n/a
 
      7th Aug 2007
I'm using OleDb. Would I use OleDbConnection.GetOldDbSchemaTable? I'm
trying that but both smalldatetime and datetime data types seem to return
135.

Can I not distinguish between the two data types when using OleDb?


"Miha Markic" <miha at rthand com> wrote in message
news:A8CBEE33-5A89-4DA0-BBA5-(E-Mail Removed)...
> You should use SqlConnection.GetSchema method to retrieve these kind of
> information.
>
> --
> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
> "Jen" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Is there a way for C# ADO.NET code to determine whether a SQL Server
>> column data type is smalldatetime vs. datetime? It looks like
>> DataColumn.DataType makes no distinction, both return DateTime.
>>

>



 
Reply With Quote
 
Miha Markic
Guest
Posts: n/a
 
      8th Aug 2007
If GetOldDbSchemaTable doesn't suite you then you should use DDL statements
(i.e. sp_columns stored procedure should do)

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Jen" <(E-Mail Removed)> wrote in message
news:OIQ$(E-Mail Removed)...
> I'm using OleDb. Would I use OleDbConnection.GetOldDbSchemaTable? I'm
> trying that but both smalldatetime and datetime data types seem to return
> 135.
>
> Can I not distinguish between the two data types when using OleDb?
>
>
> "Miha Markic" <miha at rthand com> wrote in message
> news:A8CBEE33-5A89-4DA0-BBA5-(E-Mail Removed)...
>> You should use SqlConnection.GetSchema method to retrieve these kind of
>> information.
>>
>> --
>> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
>> RightHand .NET consulting & development www.rthand.com
>> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>>
>> "Jen" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Is there a way for C# ADO.NET code to determine whether a SQL Server
>>> column data type is smalldatetime vs. datetime? It looks like
>>> DataColumn.DataType makes no distinction, both return DateTime.
>>>

>>

>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. M. Bruil Microsoft Access 2 26th Mar 2009 08:30 AM
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. M. Bruil Microsoft Access 0 25th Mar 2009 08:10 PM
conversation of char data type to smalldatetime Atilla Gunes Microsoft C# .NET 1 6th Apr 2005 04:06 PM
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. luna Microsoft ASP .NET 1 13th Feb 2004 01:15 PM
cast from datetime type to smalldatetime type? Salim Afþar Microsoft ASP .NET 2 1st Aug 2003 04:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:43 AM.