473,404 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

DataAdapter select assuming integer

How do I tell DataAdapter that Column 2 and 3 are string and not integer?
Following is the example data that comes from the .csv file

FEDERAL TAX,1084,0000
COREHCR,1084,0000
CLIENT P,1084,0000

The select is:

OleDbDataAdapter da2 As New OleDb.OleDbDataAdapter("Select * from " &
"CorelandGLConversion.csv", conn);

The problem is that it thinks the 3rd column is an integer and changes the
0000 to 0.

Can I tell it in the Select statement that the column is a varChar? I can't
do it after reading in the data as the data will already have changed the
0000 to 0 at that point.

Thanks,

Tom.
Mar 28 '07 #1
2 1798

"tshad" <t@home.comwrote in message
news:ew**************@TK2MSFTNGP06.phx.gbl...
How do I tell DataAdapter that Column 2 and 3 are string and not integer?
Following is the example data that comes from the .csv file

FEDERAL TAX,1084,0000
COREHCR,1084,0000
CLIENT P,1084,0000

The select is:

OleDbDataAdapter da2 As New OleDb.OleDbDataAdapter("Select * from " &
"CorelandGLConversion.csv", conn);

The problem is that it thinks the 3rd column is an integer and changes the
0000 to 0.

Can I tell it in the Select statement that the column is a varChar? I
can't do it after reading in the data as the data will already have
changed the 0000 to 0 at that point.
I tried to set up the table as:

DataTable DTGLConversion as DataTable;

DTGLConversion.Columns.Add("F1", System.Type.GetType("System.String"));
DTGLConversion.Columns.Add("F2", System.Type.GetType("System.String"));
DTGLConversion.Columns.Add("F3", System.Type.GetType("System.String"));

da2.Fill(DTGLConversion);
DataSetObj.Tables.Add(DTGLConversion);

This sets up the columns as strings in the DTGLConversion Table and adds it
to the Dataset but it seems the Select in the DataAdapter must have already
converted the string "0000" to integer 0 and then when I filled the
DataTable it reconverted it to "0".

How do I fix this?

Thanks,

Tom
>

Mar 28 '07 #2
bob

Hi Tom,
If you do a ' manual read' with a datareader
do you get a string?
something like
cmdSource = cmdConn.ExecuteReader(CommandBehavior.CloseConnect ion);
if ((cmdSource.Read() == true))
{
sResult = cmdSource.GetString(2);
If this gives a string of "0" I would say your only hope is to do a
file read.
hth
Bob
On Tue, 27 Mar 2007 20:12:16 -0700, "tshad" <t@home.comwrote:
>
"tshad" <t@home.comwrote in message
news:ew**************@TK2MSFTNGP06.phx.gbl...
>How do I tell DataAdapter that Column 2 and 3 are string and not integer?
Following is the example data that comes from the .csv file

FEDERAL TAX,1084,0000
COREHCR,1084,0000
CLIENT P,1084,0000

The select is:

OleDbDataAdapter da2 As New OleDb.OleDbDataAdapter("Select * from " &
"CorelandGLConversion.csv", conn);

The problem is that it thinks the 3rd column is an integer and changes the
0000 to 0.

Can I tell it in the Select statement that the column is a varChar? I
can't do it after reading in the data as the data will already have
changed the 0000 to 0 at that point.

I tried to set up the table as:

DataTable DTGLConversion as DataTable;

DTGLConversion.Columns.Add("F1", System.Type.GetType("System.String"));
DTGLConversion.Columns.Add("F2", System.Type.GetType("System.String"));
DTGLConversion.Columns.Add("F3", System.Type.GetType("System.String"));

da2.Fill(DTGLConversion);
DataSetObj.Tables.Add(DTGLConversion);

This sets up the columns as strings in the DTGLConversion Table and adds it
to the Dataset but it seems the Select in the DataAdapter must have already
converted the string "0000" to integer 0 and then when I filled the
DataTable it reconverted it to "0".

How do I fix this?

Thanks,

Tom
>>
Mar 28 '07 #3

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

Similar topics

5
by: randy | last post by:
Hello all, I have a DataTable which I am building column by column and adding rows after each new column. The DataTable columns match the columns in my database table. I'm building the...
2
by: hch | last post by:
dataAdapter.Update(data, "TableName") won’t work! I was about to deploy my first website on the Internet only to discover that the dataAdapter.Update() throws the Server Error in the third...
3
by: Tom Luetz II | last post by:
I'm having some trouble with the DataAdapter in my code. When the parameter in an OleDbCommand, which is created as having a type of OleDbType.Decimal, is set to System.DbNull, the actual value...
11
by: Siv | last post by:
Hi, I seem to be having a problem with a DataAdapter against an Access database. My app deletes 3 records runs a da.update(dt) where dt is a data.Datatable. I then proceed to update a list to...
2
by: jonefer | last post by:
I'm creating a simple search for Members, with possible 4 search parameters: Name, SSN, DOB, SEX, but (just beginning ASP.NET/VB.NET) I'm fearing that I will need to create a dataadapter for every...
6
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection =...
3
by: Rich | last post by:
What is the diffeence bewtween a dataAdapter.InsertCommand and dataAdapter.SelectCommand (and dataAdapter.UpdateCommand for that matter)? Dim da As SqlDataAdapter conn.Open da.SelectCommand =...
4
by: tshad | last post by:
How do I tell DataAdapter that Column 2 and 3 are string and not integer? Following is the example data that comes from the .csv file FEDERAL TAX,1084,0000 COREHCR,1084,0000 CLIENT P,1084,0000...
3
by: Newbie | last post by:
Hi, I have a dataadapter that contains just a single record. Dim SqlDataAdapterValues As New SqlDataAdapter("select * from tbl_formatvalue where format_id = " & intFormatInt, dbConnectionIn)...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.