473,770 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,00 00
CLIENT P,1084,0000

The select is:

OleDbDataAdapte r da2 As New OleDb.OleDbData Adapter("Select * from " &
"CorelandGLConv ersion.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 1814

"tshad" <t@home.comwrot e in message
news:ew******** ******@TK2MSFTN GP06.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,00 00
CLIENT P,1084,0000

The select is:

OleDbDataAdapte r da2 As New OleDb.OleDbData Adapter("Select * from " &
"CorelandGLConv ersion.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.Get Type("System.St ring"));
DTGLConversion. Columns.Add("F2 ", System.Type.Get Type("System.St ring"));
DTGLConversion. Columns.Add("F3 ", System.Type.Get Type("System.St ring"));

da2.Fill(DTGLCo nversion);
DataSetObj.Tabl es.Add(DTGLConv ersion);

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.Execute Reader(CommandB ehavior.CloseCo nnection);
if ((cmdSource.Rea d() == true))
{
sResult = cmdSource.GetSt ring(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.comwrot e:
>
"tshad" <t@home.comwrot e in message
news:ew******* *******@TK2MSFT NGP06.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,0 000
CLIENT P,1084,0000

The select is:

OleDbDataAdapt er da2 As New OleDb.OleDbData Adapter("Select * from " &
"CorelandGLCon version.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("F 1", System.Type.Get Type("System.St ring"));
DTGLConversion .Columns.Add("F 2", System.Type.Get Type("System.St ring"));
DTGLConversion .Columns.Add("F 3", System.Type.Get Type("System.St ring"));

da2.Fill(DTGLC onversion);
DataSetObj.Tab les.Add(DTGLCon version);

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
2254
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 DataTable first and I then want to roll through the DataTable while in memory checking for errors and then commit the rows to my database table (btw this is in ASP.NET). Is it possible to have data in a datable before attaching at DataAdapter? I'm a...
2
4271
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 underline. It was working fine before. ConnectionString in Web.config: ----------------------------------------- <?xml version="1.0" encoding="utf-8" ?> <configuration>
3
1728
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 posted to the database upon execution of the Insert command is a floating point value of zero (0.0, actually). The DataAdapter is associated with a DataGrid. When a row is inserted into the grid, the column may contain either nothing "(null)" or...
11
2249
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 reflect that the 3 items have been deleted only to discover that the 3 items appear, however when I click on them to display their information which runs a datareader over the same database it appears that the data has now gone. I wondered whether...
2
1337
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 possible combination of fields entered to eliminate a blank parameter. Does a parameterized DataAdapter automatically take care of this so I can use the following SQL without having to worry about blank textboxes?: SELECT * From Membership...
6
14002
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 = conn da.UpdateCommand.CommandText = "Update tbl1 set fld1 = 'test' where ID = 1" da.Update(tblx) '--tblx/tbl1 not getting updated here.
3
12514
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 = New SqlCommand da.SelectCommand.Connectoin = conn da.SelectCommand.CommandType = Command.Text da.SelectCommand.CommandText = "insert Into tbl1 Select * from tbl2" da.SelectCommand.ExecuteNonQuery
4
1666
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 The select is: Dim da2 As New OleDb.OleDbDataAdapter("Select * from " &
3
2316
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) SqlDataAdapterJobs.Fill(dsFormats, "formatvalues") I want to get the value for column customer_id from this dataset.
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10260
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...
1
10038
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
9906
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
8933
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...
0
6712
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
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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.