473,666 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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(fil ePath),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(fil ePath),conn)
But it doesn't work.

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

Thanks,
Pehuén.
Jan 26 '09 #1
1 2268
pehuen
2 New Member
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(fil ePath),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(fil ePath),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

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

Similar topics

14
3420
by: | last post by:
Hi, I was performing SQL UPDATE queries and I notice that they SUCCEED on the ExecuteNonQuery() call with NO exceptions raised BUT they fail at the Database. They say they succeed in the code but they fail at the database. To fix this they Parameters.Add must be called in the ORDER they are in the SQL STATEMENT. This is confusing and bad.
14
5406
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB 7.2 environment, the choices the optimizer makes often seem flaky. But this last example really floored me. I was hoping someone could explain why I get worse response time when the optimizer uses two indexes, than when it uses one. Some context:
2
23921
by: Joe | last post by:
Hi All, I am new to using the Access DB and I need some help if someone is able to give it to me. What I want to do is get the names of the columns of certain tables. Not the data in the table but the table column names. I've seen other posts that suggest using the SQL command DESCRIBE but I can't get it to work for some reason. Other posts have code samples but they're written in VB which I am not familiar with. I
5
4342
by: premmehrotra | last post by:
I am using Microsoft Access 2000 and Oracle 9.2.0.5 on Windows 2000. When I export a table from Access to Oracle using ODBC I get error: ORA 972 identifier too long I think the error is because one or more columns in Access table are longer than 30 characters. My question is how one can overcome this problem. I also see several column names which have /, ? or spaces in name
3
8823
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I don't think I made any changes to either page other than changing the user control that creates the header). Server Error in '/myApp' Application. ---------------------------------------------------------------------------- ----
8
5395
by: erin.sebastian | last post by:
Hi all, I have a really silly problem that i can't find the answer too. I am working with VB.NET and i am trying to insert a new record into my access database (pretty easy right?) well i am getting a syntax error in my SQL statement and nothing i do will correct it. It looks FINE to me, can anyone help me out?? Thanks so much in advance, here is the code i am using Dim cn As OleDbConnection Dim cmd As OleDbCommand
0
942
by: Mythran | last post by:
I can get the column names and OleDbType enumeration value for any given table using VB.Net and the OleDb namespace classes. Is there a way for me to get the Access alias/name of the data type? I am writing a little app that displays microsoft access tables and queries...the schemas for the queries. Second question is, how can I get the column names for Queries using OleDb? I can get the column names for tables using the method...
4
5612
by: SAL | last post by:
Hello, I am using OLEDB to access Excel, and what I have read you can access Named Ranges but I am having trouble doing so. The following are lines of code I've tried in my C# program to access Named ranges but don't work. Is the something else I need to do? string sqlCommand = "Select * From "; string sqlCommand = "Select * From "; string sqlCommand = "Select * From ";
0
3969
by: mwenz | last post by:
I am trying to update an Access table using OLEDB in VB.Net 2005. I can add rows but I cannot update them. Code to instantiate the Access database and table... Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & db.Name) conn.Open() Dim oda As New OleDb.OleDbDataAdapter("select " & sqlCols & " from ;", conn) Dim cb As New OleDb.OleDbCommandBuilder(oda) cb.QuotePrefix = "" oda.UpdateCommand =...
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8550
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
8639
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...
1
6192
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5663
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
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1772
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.