Re: How can I check the data type of a field in the DataReader ?

Tech-Archive recommends: Speed Up your PC by fixing your registry



Now, I seem not to be able to find how to find a data type of a field in a
DataSet.
Dim aRow As DataRow()

m_cmdSQL = New SqlClient.SqlCommand
With m_cmdSQL
.Connection = adoCon
.CommandText = sSQL
End With
m_daSQL = New SqlClient.SqlDataAdapter
m_dsSQL = New DataSet
m_daSQL.SelectCommand = m_cmdSQL
m_daSQL.Fill(m_dsSQL)
for arow in m_dsSQL.Tables(0).rows
--> How do you find the data type of column 1, 2, etc ?

"fniles" <fniles@xxxxxxxxxx> wrote in message
news:OnztqPKnHHA.4628@xxxxxxxxxxxxxxxxxxxxxxx
I am using VB.NET 2005 and SQLDataReader.
How can I check the data type of a field in the DataReader ? Thank you.

Dim cmdSQL As SqlClient.SqlCommand
Dim drSQL As SqlClient.SqlDataReader

sSQL = "select * from " & sTableName
cmdSQL = New SqlClient.SqlCommand
With cmdSQL
.Connection = m_Connection
.CommandText = sSQL
End With
drSQL = cmdSQL.ExecuteReader()
iFieldCnt = drSQL.FieldCount
Do While drSQL.Read
For x = 0 To iFieldCnt - 1
If drSQL.Item(x).GetType("system.string") Then ----> i want to
check of the data type of this column is string, how can I do that ?
Otherwise, how can I check the data type of this column ?




.



Relevant Pages

  • Re: How can I get Atributes from the field of the table via VBA
    ... I think is data type in code ... "Brendan Reynolds" wrote: ... I don't know how you could get the caption and format, ... Dim tdf As DAO.TableDef ...
    (microsoft.public.access.adp.sqlserver)
  • RE: Dynamically declare and populate variables
    ... reason that I ask is that you can't declare variables as you describe. ... Declares an array of strings. ... Dim DataVarsAs Long ... Your array DataVars can only be 1 data type. ...
    (microsoft.public.excel.programming)
  • Re: new to coding
    ... I think John was wondering why you were using VB6 Express edition rather ... Integer is the correct data type to use. ... Dim one As String = "1" ...
    (microsoft.public.dotnet.general)
  • Re: new to coding
    ... Thank you Kevin, that helped but I am still confused as to why my code is ... Integer is the correct data type to use. ... Dim one As String = "1" ... incorrect data types by using the compiler option strict off, ...
    (microsoft.public.dotnet.general)
  • Re: How can I get Atributes from the field of the table via VBA
    ... because each character can hold any character in the double-byte ... I think is data type in code ... "Brendan Reynolds" wrote: ... Dim tdf As DAO.TableDef ...
    (microsoft.public.access.adp.sqlserver)