[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.
Re: Grabbing Data Type of each column
The DataColumn object has a DataType property. Does that help?
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