By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,964 Members | 1,290 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,964 IT Pros & Developers. It's quick & easy.

JET.OLEDB: how to access columns without names in a csv txt

P: 2
I didn't know where to place this issue, because it either C# or .net or I don't know. So I placed it here so it can be moved by an admin.

Hello.
I'm using c# and OleDb to access a txt (comma separated values) file which has this format:

05223,1.5
05548,4.9

It doesn't have header, so when I use an OleDbCommand with this query:
("select * from "+ System.IO.Path.GetFileName(filePath),conn)
I get:
ds.Table[0].Rows[0][0] = 5223
ds.Table[0].Rows[0][1] = 1.5
But I need a string (starting whit zero). I mean that first field should be 05223.

I tried changing the query:
("select cast([0] as nvarchar(64)), [1] from "+ System.IO.Path.GetFileName(filePath),conn)
But it doesn't work.

Does anyone knows how to leave that first field into string?

Thanks,
Pehuén.
Jan 26 '09 #1
Share this Question
Share on Google+
1 Reply


P: 2
Hello.
I'm using c# and OleDb to access a txt (comma separated values) file which has this format:

05223,1.5
05548,4.9

It doesn't have header, so when I use an OleDbCommand with this query:
("select * from "+ System.IO.Path.GetFileName(filePath),conn)
I get:
ds.Table[0].Rows[0][0] = 5223
ds.Table[0].Rows[0][1] = 1.5
But I need a string (starting whit zero). I mean that first field should be 05223.

I tried changing the query:
("select cast([0] as nvarchar(64)), [1] from "+ System.IO.Path.GetFileName(filePath),conn)
But it doesn't work.

Does anyone knows how to leave that first field into string?
I believe the query should be different, the file should be red differently. (¿?)

Thanks,
Pehuén.
Jan 27 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.