473,657 Members | 2,481 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.SqlCo mmand
Dim drSQL As SqlClient.SqlDa taReader

sSQL = "select * from " & sTableName
cmdSQL = New SqlClient.SqlCo mmand
With cmdSQL
.Connection = m_Connection
.CommandText = sSQL
End With
drSQL = cmdSQL.ExecuteR eader()
iFieldCnt = drSQL.FieldCoun t
Do While drSQL.Read
For x = 0 To iFieldCnt - 1
If drSQL.Item(x).G etType("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 ?
May 22 '07 #1
2 21789
Never mind, I found it.
If drSQL.GetFieldT ype(x) Is GetType(String) Or drSQL.GetFieldT ype(x) Is
GetType(Date) Then

"fniles" <fn****@pfmail. comwrote in message
news:On******** ******@TK2MSFTN GP06.phx.gbl...
>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.SqlCo mmand
Dim drSQL As SqlClient.SqlDa taReader

sSQL = "select * from " & sTableName
cmdSQL = New SqlClient.SqlCo mmand
With cmdSQL
.Connection = m_Connection
.CommandText = sSQL
End With
drSQL = cmdSQL.ExecuteR eader()
iFieldCnt = drSQL.FieldCoun t
Do While drSQL.Read
For x = 0 To iFieldCnt - 1
If drSQL.Item(x).G etType("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 ?


May 22 '07 #2
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.SqlCo mmand
With m_cmdSQL
.Connection = adoCon
.CommandText = sSQL
End With
m_daSQL = New SqlClient.SqlDa taAdapter
m_dsSQL = New DataSet
m_daSQL.SelectC ommand = 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" <fn****@pfmail. comwrote in message
news:On******** ******@TK2MSFTN GP06.phx.gbl...
>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.SqlCo mmand
Dim drSQL As SqlClient.SqlDa taReader

sSQL = "select * from " & sTableName
cmdSQL = New SqlClient.SqlCo mmand
With cmdSQL
.Connection = m_Connection
.CommandText = sSQL
End With
drSQL = cmdSQL.ExecuteR eader()
iFieldCnt = drSQL.FieldCoun t
Do While drSQL.Read
For x = 0 To iFieldCnt - 1
If drSQL.Item(x).G etType("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 ?


May 22 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
26268
by: SD | last post by:
Hi, This is driving me nuts, I have a table that stores notes regarding an operation in an IMAGE data type field in MS SQL Server 2000. I can read and write no problem using Access using the StrConv function and I can Update the field correctly in T-SQL using: DECLARE @ptrval varbinary(16) SELECT @ptrval = TEXTPTR(BITS_data)
4
3141
by: N J | last post by:
Hi, CurrentDb.Execute "Update tblDelayedOrders Set DELAYED = True Where ID = " & Me.txtOrderNumber & ";", dbfailonerror Me.StatusListBox.AddItem "ORDER # " & Me.txtOrderNumber & " MARKED AS DELAYED " & "" & "", 0 When I change Where ID to Where TRACKING (another text field) I get the error Data Type Mismatch in expression critera, or something like that
0
1697
by: selacika | last post by:
Hi all; My question is about how to get non-font information part of a field of text data type using an sql sentence. Shortly how to get pure info from a text data type field. Example: Value of Field1: {\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset162{\*\fname Arial;}Arial TUR;}{\f1\fnil MS Sans Serif;}} \viewkind4\uc1\pard\lang1055\f0\fs30 Testing Testing\f1\fs16 \par } Is there any sql function or method to get this part...
1
2257
by: ritu raj shriwastaw | last post by:
I am using window xp and php trait(php3.1,mysql4.2).i have one field is of memo data type and I am unable to retrieve data from that memo data type field. what query I should write?
2
2594
by: nduerr | last post by:
I have a table with pdf files stored in an attachment data type field in a 2007 Access File. I would like to run a query that would select a group out of this table (easy part) then send the pdf file stored in the attachment field in each of the selected records to a specific e- mail address as an attachment to the e-mail. The pdf files can be zipped together or left separately. First off, Is this possible? I haven't found a lot of...
0
2736
by: bkberg05 | last post by:
Hi - I currently use Access 2003 and have documents stored in an OLE data type field. I want be able to write a query that contains various other data elements from the table plus the OLE field and export these to an excel file. The query itself shows the document in the OLE field, but when I export the spreadsheet to Excel, the field holding the document shows up blank. Doing research, I saw Access 2007 had a different data type called...
1
4451
by: kimsengora | last post by:
Ex. I need to fill in values argument Field1 is text Field2 is image Insert into tbl1 values("'+val1+"','+val2+'") val2 is image like 0x424DFE9D00000000000036000000..................................... I really stuck on this with image values because I have to BCP out my data and and generate the insert statement with value data like above back to database
1
3072
by: littlemaster | last post by:
I am having table in psql it has one field as integer array data type. From rails application I was not able to insert value in that filed. Example: Need to add multiple userid in the name field. create table users(name integer,id serial); a=10 obj-User.new
0
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7327
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.