|
-
Nov 2nd, 2005, 09:30 AM
#1
Thread Starter
Junior Member
[RESOLVED] Grabbing Data Type of each column
Hello, Im using a datagrid to find/replace certain dates, strings, words etc. The database can contain any type of field created by a user in another application, all I need to know is how to find out what types of variables are stored in each column before I can filter things out. Right now Im using something like this:
VB Code:
aFilter = "[Summary] Like '" & txtfilter.Text & "*'"
DS1.Tables("tblDoc").DefaultView.RowFilter = aFilter
Of course this works fine for strings but not on dates or any integers. So my plan is to have a case structure to format my sql query correctly depending on data type.
Im not the best coder (kinda part time) so please forgive any idiocy included in the above text.
Last edited by IgnoramusLLJK; Nov 2nd, 2005 at 10:10 AM.
-
Nov 2nd, 2005, 09:37 AM
#2
Re: Grabbing Data Type of each column
The DataColumn object has a DataType property. Does that help?
-
Nov 2nd, 2005, 10:08 AM
#3
Thread Starter
Junior Member
Re: Grabbing Data Type of each column
Okay I got it, thanks mang! Heres my sloppy code incase anyone cares
VB Code:
For x = 0 To Me.DS1.tblDoc.Columns.Count
Dim aCol As System.Data.DataColumn = Me.DS1.tblDoc.Columns(x)
Select Case aCol.DataType.Name
Case "String"
Console.WriteLine(aCol.ColumnName & ": As String")
Case "Byte"
Console.WriteLine(aCol.ColumnName & ": As Byte")
Case "Int16"
Console.WriteLine(aCol.ColumnName & ": As Int16")
Case Else
Console.WriteLine("Something else")
End Select
next
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|