473,320 Members | 1,955 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,320 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:

Dim 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
4 1643
"tshad" <t@home.comwrote in message
news:u5*************@TK2MSFTNGP05.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:

Dim 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:

Dim 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
On Mar 28, 5:11 am, "tshad" <t...@home.comwrote:
"tshad" <t...@home.comwrote in message

news:u5*************@TK2MSFTNGP05.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:
Dim 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:

Dim 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- Hide quoted text -

- Show quoted text -
Try to use schema.ini file

http://msdn.microsoft.com/library/de...a_ini_file.asp

I think it should be similar to this

[CorelandGLConversion.csv]
Format=Delimited(;)
ColNameHeader=True
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char

and place that file in the same folder as the CSV file

Mar 28 '07 #3
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@y66g2000hsf.googlegr oups.com...
On Mar 28, 5:11 am, "tshad" <t...@home.comwrote:
>"tshad" <t...@home.comwrote in message

news:u5*************@TK2MSFTNGP05.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:
Dim 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:

Dim 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- Hide quoted text -

- Show quoted text -

Try to use schema.ini file

http://msdn.microsoft.com/library/de...a_ini_file.asp

I think it should be similar to this

[CorelandGLConversion.csv]
Format=Delimited(;)
ColNameHeader=True
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char

and place that file in the same folder as the CSV file
It almost works. It does give me everything. But it doesn't split each
line into 3 columns.

It makes each line one columns and ignores the comma separators. If I
change the name of the file in the schema file (so that it doesn't use it),
it splits each line (row) into 3 columns.

column 1 = FEDERAL TAX,1084,0000
column 2 = Null
column 3 = Null

If I leave out the schema.ini file (or just change the file name in the
file), I get:

column 1 = FEDERAL TAX
column 2 = 1084
column 3 = 0

Thanks,

Tom
Mar 28 '07 #4
Found it.

I needed to have:

Format=CSVDelimited

in my file.

Thanks,

Tom
"tshad" <t@home.comwrote in message
news:Op**************@TK2MSFTNGP06.phx.gbl...
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@y66g2000hsf.googlegr oups.com...
>On Mar 28, 5:11 am, "tshad" <t...@home.comwrote:
>>"tshad" <t...@home.comwrote in message

news:u5*************@TK2MSFTNGP05.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:

Dim 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:

Dim 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- Hide quoted text -

- Show quoted text -

Try to use schema.ini file

http://msdn.microsoft.com/library/de...a_ini_file.asp

I think it should be similar to this

[CorelandGLConversion.csv]
Format=Delimited(;)
ColNameHeader=True
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char

and place that file in the same folder as the CSV file

It almost works. It does give me everything. But it doesn't split each
line into 3 columns.

It makes each line one columns and ignores the comma separators. If I
change the name of the file in the schema file (so that it doesn't use
it), it splits each line (row) into 3 columns.

column 1 = FEDERAL TAX,1084,0000
column 2 = Null
column 3 = Null

If I leave out the schema.ini file (or just change the file name in the
file), I get:

column 1 = FEDERAL TAX
column 2 = 1084
column 3 = 0

Thanks,

Tom


Mar 28 '07 #5

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: Eric A. Johnson | last post by:
I'm using ADO style. I have an Access database with four tables that I will want to do queries on. I will want to do queries on all four tables, at least individually, and possibly at the same...
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 =...
2
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.