Click here to Skip to main content
15,889,424 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI..
I am using VB.Net with access DB and i have 1 table in DB and in that i have column of data type short text with some size.
Now the thing is i want to know the data type of column and if it is short text then field size of this column using vb.net code.

What I have tried:

VB
sSql = "select STATUS from tblTimeRegister"
ds = New DataSet
If Common.servername = "Access" Then
    adapA = New OleDbDataAdapter(sSql, con1Tmp)
    adapA.Fill(ds)
Else
    adap = New SqlDataAdapter(sSql, Common.con)
    adap.Fill(ds)
End If
'Dim dc As DataColumn =
MsgBox(ds.Tables(0).Columns(0).DataType.ToString)

here i can get the datatype, but it gives same value for longtext and short text that is system.string.
so how to make out the difference between this two
Posted
Updated 22-Jul-19 8:53am
v2

1 solution

Retrieving Database Schema Information | Microsoft Docs[^]

Basically, you need to call GetOleDbSchemaTable[^] on your connection, passing in OleDbSchemaGuid.Columns[^] as the schema, and an array containing (Nothing, Nothing, "tblTimeRegister", "STATUS") for the restrictions.

The returned schema table[^] will tell you everything you need to know about the column.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900