문제

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