Вопрос

I have the following code

Dim dbMnt As OleDb.OleDbConnection
dbMnt = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\temp\data.mdb")
dbMnt.Open()

Dim qdfTabCols As DataTable = dbMnt.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Columns, New Object(){Nothing, Nothing, "Table1")

Dim dr As DataRow
For Each dr In qdfTabCols
    Msgbox(dr("TABLE_NAME") & " " & dr("COLUMN_NAME") & " " & dr("DATA_TYPE"))
    'In here I would like to test the column data type
Next

Inside the "For Each" I would like to test for the various column data types and handle them differently. I used to just use: dbText, dbMemo, dbDate. How do you write this "If" statement in VB.net?

If (dr("DATA_TYPE") = ????) Then
Это было полезно?

Решение

If I'm not mistaken , DATA_TYPE will contain OleDbType Enum. Try This :

If (dr("DATA_TYPE") = OleDb.OleDbType.DBDate) Then
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top