I have been using a schema.ini file to define the columns of my .csv files
that has been working fine.
But I just tried one where it doesn't work.
I have the following schema.ini file:
************************************************** *********
[CGLConversion.csv]
Format=CSVDelimited
ColNameHeader=False
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char
Col4=F4 Char
Col5=F5 Char
[SGLConversion.csv]
Format=CSVDelimited
ColNameHeader=False
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char
Col4=F4 Char
Col5=F5 Char
Col6=F6 Char
[tempInvoice.csv]
Format=CSVDelimited
ColNameHeader=False
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char
Col4=F4 Char
Col5=F5 Char
Col6=F6 Char
Col7=F7 Char
Col8=F8 Char
************************************************** ******
The first 2 files work fine. But the tempInvoice.csv is giving me an error
that says it expects column 3 to be numeric????
Here is the error:
************************************************** ***********
ex.Message "System.FormatException: Input string was not in a correct
format.
at System.Number.ParseDouble(String s, NumberStyles style,
NumberFormatInfo info)
at System.Double.Parse(String s, NumberStyles style, IFormatProvider
provider)
at System.Convert.ToDouble(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToDouble(IFormat Provider provider)
at System.Convert.ToDouble(Object value)
at System.Data.Common.DoubleStorage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't
store <004Oin F3 Column. Expected type is Double." String
************************************************** *************
The .csv file is:
************************************************** *********
"8005","C COMPANIES INC","000","GROSS WAGES","1,7.11",
"","","001","FICA-OASDI",108.37,
"","","002","FICA-MEDICARE",25.34,
"","","003","FUTA",1.87,
"","","004","SUTA",13.82,
"","","004O","OTHER STATE TAX",0.24,
"","","005","WORKERS COMPENSATION",0.00,
************************************************** **********
If I take out the line that has "004O" out, it works fine. But if I have
defined all the columns as Char, then why the error?
The code looks like:
************************************************** *********
Dim path As String = "C:\ImportFile\"
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
If f.Exists(pathfile) Then
Try
Dim da As New OleDb.OleDbDataAdapter("Select * from " &
"tempInvoice.csv", conn)
da.Fill(DataSetObj)
Catch ex As Exception
TextBox3Error.Text = ex.Message
Exit Sub
End Try
End If
************************************************** ********
It gets to the .fill line then the Catch section.
Thanks,
Tom 2 5801
On Apr 11, 3:14 pm, "tshad" <t...@home.comwrote:
I have been using a schema.ini file to define the columns of my .csv files
that has been working fine.
But I just tried one where it doesn't work.
I have the following schema.ini file:
************************************************** *********
[CGLConversion.csv]
Format=CSVDelimited
ColNameHeader=False
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char
Col4=F4 Char
Col5=F5 Char
[SGLConversion.csv]
Format=CSVDelimited
ColNameHeader=False
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char
Col4=F4 Char
Col5=F5 Char
Col6=F6 Char
[tempInvoice.csv]
Format=CSVDelimited
ColNameHeader=False
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char
Col4=F4 Char
Col5=F5 Char
Col6=F6 Char
Col7=F7 Char
Col8=F8 Char
************************************************** ******
The first 2 files work fine. But the tempInvoice.csv is giving me an error
that says it expects column 3 to be numeric????
Here is the error:
************************************************** ***********
ex.Message "System.FormatException: Input string was not in a correct
format.
at System.Number.ParseDouble(String s, NumberStyles style,
NumberFormatInfo info)
at System.Double.Parse(String s, NumberStyles style, IFormatProvider
provider)
at System.Convert.ToDouble(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToDouble(IFormat Provider provider)
at System.Convert.ToDouble(Object value)
at System.Data.Common.DoubleStorage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't
store <004Oin F3 Column. Expected type is Double." String
************************************************** *************
The .csv file is:
************************************************** *********
"8005","C COMPANIES INC","000","GROSS WAGES","1,7.11",
"","","001","FICA-OASDI",108.37,
"","","002","FICA-MEDICARE",25.34,
"","","003","FUTA",1.87,
"","","004","SUTA",13.82,
"","","004O","OTHER STATE TAX",0.24,
"","","005","WORKERS COMPENSATION",0.00,
************************************************** **********
If I take out the line that has "004O" out, it works fine. But if I have
defined all the columns as Char, then why the error?
The code looks like:
************************************************** *********
Dim path As String = "C:\ImportFile\"
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
If f.Exists(pathfile) Then
Try
Dim da As New OleDb.OleDbDataAdapter("Select * from " &
"tempInvoice.csv", conn)
da.Fill(DataSetObj)
Catch ex As Exception
TextBox3Error.Text = ex.Message
Exit Sub
End Try
End If
************************************************** ********
It gets to the .fill line then the Catch section.
Thanks,
Tom
Tom, as a test, try putting a character into this line and running
again. change 000 to 000F
"8005","C COMPANIES INC","000F","GROSS WAGES","1,7.11",
It may be looking at the first datatype to get entered in that column
and setting the columns datatype that way. It's been a while since i
switched from csv to xml so its just a guess.
"Charlie Brown" <cb****@duclaw.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
On Apr 11, 3:14 pm, "tshad" <t...@home.comwrote:
>I have been using a schema.ini file to define the columns of my .csv files that has been working fine.
But I just tried one where it doesn't work.
I have the following schema.ini file:
************************************************* ********** [CGLConversion.csv] Format=CSVDelimited ColNameHeader=False Col1=F1 Char Col2=F2 Char Col3=F3 Char Col4=F4 Char Col5=F5 Char
[SGLConversion.csv] Format=CSVDelimited ColNameHeader=False Col1=F1 Char Col2=F2 Char Col3=F3 Char Col4=F4 Char Col5=F5 Char Col6=F6 Char
[tempInvoice.csv] Format=CSVDelimited ColNameHeader=False Col1=F1 Char Col2=F2 Char Col3=F3 Char Col4=F4 Char Col5=F5 Char Col6=F6 Char Col7=F7 Char Col8=F8 Char ************************************************* *******
The first 2 files work fine. But the tempInvoice.csv is giving me an error that says it expects column 3 to be numeric???? Here is the error: ************************************************* ************ ex.Message "System.FormatException: Input string was not in a correct format. at System.Number.ParseDouble(String s, NumberStyles style, NumberFormatInfo info) at System.Double.Parse(String s, NumberStyles style, IFormatProvider provider) at System.Convert.ToDouble(String value, IFormatProvider provider) at System.String.System.IConvertible.ToDouble(IFormat Provider provider) at System.Convert.ToDouble(Object value) at System.Data.Common.DoubleStorage.Set(Int32 record, Object value) at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <004Oin F3 Column. Expected type is Double." String ************************************************* **************
The .csv file is: ************************************************* ********** "8005","C COMPANIES INC","000","GROSS WAGES","1,7.11", "","","001","FICA-OASDI",108.37, "","","002","FICA-MEDICARE",25.34, "","","003","FUTA",1.87, "","","004","SUTA",13.82, "","","004O","OTHER STATE TAX",0.24, "","","005","WORKERS COMPENSATION",0.00, ************************************************* ***********
If I take out the line that has "004O" out, it works fine. But if I have defined all the columns as Char, then why the error?
The code looks like:
************************************************* ********** Dim path As String = "C:\ImportFile\" Dim ConStr As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _ path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\""" Dim conn As New OleDb.OleDbConnection(ConStr)
If f.Exists(pathfile) Then Try Dim da As New OleDb.OleDbDataAdapter("Select * from " & "tempInvoice.csv", conn) da.Fill(DataSetObj) Catch ex As Exception TextBox3Error.Text = ex.Message Exit Sub End Try End If ************************************************* *********
It gets to the .fill line then the Catch section.
Thanks,
Tom
Tom, as a test, try putting a character into this line and running
again. change 000 to 000F
"8005","C COMPANIES INC","000F","GROSS WAGES","1,7.11",
It may be looking at the first datatype to get entered in that column
and setting the columns datatype that way. It's been a while since i
switched from csv to xml so its just a guess.
I assumed that was the case, but that is not supposed to be the case if you
are using a schema.ini file where you define the columns.
I think I may have figured out the problem. In my example, I am filling a
DataSet. If I change the code to fill a DataTable and then add that table
to the DataSet, that seems to solve the problem.
It seems to be because I already have 2 tables in the DataSet. If I have no
tables in the DataSet already, then it works fine. But if there is a table
there, what seems to be happening is that it is doing an insert into the
table of DataSet.Tables(0) which has no name (except for the "Table1" given
it when I filled the first table).
I can also do the same line that fills the DataSet if I give it a name:
da.Fill(DataSetObj,"Invoice")
Thanks,
Tom This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: C. M. Sperberg-McQueen |
last post by:
wooks (wookiz@hotmail.com) wrote:
> <?xml version='1.0'?>
> <userlogin xmlns="urn:faster:userlogin"
> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
> <login>mick</login>
> ...
|
by: Pieter |
last post by:
I've read a lot of posts on "why relax ng is so very good" and on "why
w3c xml schema should be the only schema language". I'm, however,
still not clear on why I should prefer one over the other.
...
|
by: joes |
last post by:
Hello there
I tried for several days to get a simple validation with xml schema &
xerces working. Goal for me is tuse JAXP and not specific Xerces
classes. I don't get the point what I am doing...
|
by: william_hulse |
last post by:
The general process i am currently working on is this:
STEP 1 xml doc1 is transformed using stylesheet1 to produce xml doc2
- xml doc1 has a namespace declaration as follows...
<?xml...
|
by: wackyphill |
last post by:
I know in SQL Server the terms Database and Catalog are used
interchangably. But a table is also assigned a schema. As seen in the
INFORMATION_SCHEMA.Tables View. I don't get what this schema...
|
by: Poonam |
last post by:
Hi,
Can some one please help me with (or point me to) a very simple but
working code sample that shows how to import XML Schema.
I have tried many samples out there on internet but nothing seems...
|
by: Derek |
last post by:
I am creating an intranet using Visual Web Developer Express Edition.
Everything has been working OK until yesterday when I started getting 62
messages all beginning "Could not find schema...
|
by: Reuven Nisser |
last post by:
Hi,
How can I describe an XML like this:
<X>
<Y/>
<Z/>
<Y/>
<Y/>
</X>
|
by: Chris Lieb |
last post by:
I am new to XML Schema and am running into a bit of a snag. I have
defined an XML-based scripting language for an updater program that I
am working on. I would like to make a schema for this...
|
by: cmay |
last post by:
I am beginning to wonder if it is not possible to get this working.
I am trying to do:
<root>
<a/>
<b/>
<c/>
</root>
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
| |