If InStr(str, "decimal") &gt

全文

(1)

Public Function getFieldType(ByVal strTBL As String, ByRef fldType() As String, ByRef fldLength() As Integer) As Boolean

Try

If strTBL = "" Then Return False Exit Function End If

Dim str As String, enVl() As String, sstr As String

Dim i As Integer, ln As Integer, fl As Integer, sl As Integer, ml As Integer

Dim tblReader As OdbcDataReader str = "Describe " & strTBL & ";"

myCmd = New OdbcCommand(str, myCon) tblReader = myCmd.ExecuteReader

i = 0

While tblReader.Read

str = tblReader.Item(1).ToString ln = 0

If InStr(str, "int") > 0 Then fldType(i) =

"Numeric"

If InStr(str, "decimal") > 0 Then fldType(i) = "Numeric"

ln = 2 End If

If InStr(str, "float") > 0 Then fldType(i) = "Numeric"

ln = 2 End If

If InStr(str, "double") > 0 Then fldType(i) = "Numeric"

ln = 2

(2)

End If

If InStr(str, "real") > 0 Then fldType(i) = "Numeric"

ln = 2 End If

If InStr(str, "tinyint(1)") > 0 Or InStr(str,

"boolean") > 0 Then

fldType(i) = "Boolean"

End If

If InStr(str, "char") > 0 Or InStr(str, "var") >

0 Then

If InStr(str, "varbinary") > 0 Then fldType(i) = "Binary"

Else

fldType(i) = "String"

End If fl = 0 sl = 0

If InStr(str, "(") > 0 Then fl = InStr(str, "(")

sl = InStr(str, ")")

fldLength(i) = Val(Mid(str, fl + 1, (sl - fl - 1))) + ln

End If End If

If InStr(str, "enum") > 0 Then fldType(i) = "Enum"

fldLength(i) = 10 fl = InStr(str, "(") sl = InStr(str, ")")

sstr = Mid(str, fl + 1, sl - fl - 1) enVl = Split(sstr, ",")

ml = 0

(3)

For ei = 0 To UBound(enVL)

If LenUstr(enVL(ei)) > ml Then ml = LenUstr(enVL(ei))

Next

fldLength(i) = ml End If

If InStr(str, "date") > 0 Then fldType(i) =

"Date"

If InStr(str, "timestamp") > 0 Then fldType(i) = "Stamp"

fldLength(i) = 24 End If

If InStr(str, "text") > 0 Then fldType(i) =

"Text"

If InStr(str, "blob") > 0 Then fldType(i) =

"Blob"

i = i + 1 End While

tblReader.Close() Return True

Catch ex As Exception MsgBox(ex.Message) Return False

End Try End Function

數據

Updating...

參考文獻

Updating...

相關主題 :