473,320 Members | 1,691 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.

Creating an in memory table

I have the following Test.CSV file:
Col1,Col2,Col3
1,4,7
2,5,8
3,6,9

I have created a table:
DataColumn dc1 = new DataColumn("B1");
DataColumn dc2 = new DataColumn("B2);
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);

I want to select Col1, Col2 into dt.

How should I do it?
I can do the following:
using (OleDbCommand cmd =
new OleDbCommand("SELECT * FROM Test.csv" , conn))
{
da = new OleDbDataAdapter(cmd);
da.Fill(ds);
}

But I want to just have selected values into dt.

Oct 25 '07 #1
5 1588
If you only want selected values, then you will have to adjust the text
in your OleDbCommand to filter out the values you don't want to see.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<Hi**************@gmail.comwrote in message
news:11**********************@t8g2000prg.googlegro ups.com...
>I have the following Test.CSV file:
Col1,Col2,Col3
1,4,7
2,5,8
3,6,9

I have created a table:
DataColumn dc1 = new DataColumn("B1");
DataColumn dc2 = new DataColumn("B2);
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);

I want to select Col1, Col2 into dt.

How should I do it?
I can do the following:
using (OleDbCommand cmd =
new OleDbCommand("SELECT * FROM Test.csv" , conn))
{
da = new OleDbDataAdapter(cmd);
da.Fill(ds);
}

But I want to just have selected values into dt.

Oct 25 '07 #2
On Oct 26, 2:55 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
If you only want selected values, then you will have to adjust the text
in your OleDbCommand to filter out the values you don't want to see.

Thank you for the reply.
But I am not able to understand ur suggestion.
Do you mean using (OleDbCommand cmd = new OleDbCommand("SELECT Col1,
Col2 into dt FROM Test.csv" , conn))

or something else?

-Thanks.
Oct 26 '07 #3
Yes, that's pretty much it. You will have to put a filter on it if you
want to filter out rows (a where clause) in the results.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<Hi**************@gmail.comwrote in message
news:11**********************@t8g2000prg.googlegro ups.com...
On Oct 26, 2:55 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
> If you only want selected values, then you will have to adjust the
text
in your OleDbCommand to filter out the values you don't want to see.


Thank you for the reply.
But I am not able to understand ur suggestion.
Do you mean using (OleDbCommand cmd = new OleDbCommand("SELECT Col1,
Col2 into dt FROM Test.csv" , conn))

or something else?

-Thanks.


Oct 26 '07 #4
On Oct 26, 7:35 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Yes, that's pretty much it. You will have to put a filter on it if you
want to filter out rows (a where clause) in the results.
Thanks for reply.
I had already tried it. In OleDb it doesn't work.

Oct 26 '07 #5
If it doesn't work, then you can load the entire contents into a
DataTable, and then create a DataView and place a filter on the items in the
DataTable through the view.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<Hi**************@gmail.comwrote in message
news:11**********************@v29g2000prd.googlegr oups.com...
On Oct 26, 7:35 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
> Yes, that's pretty much it. You will have to put a filter on it if
you
want to filter out rows (a where clause) in the results.
Thanks for reply.
I had already tried it. In OleDb it doesn't work.

Oct 26 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Antar | last post by:
Hi, I'm kind of a newbie on DB management but I have to deal with a huge DB used for real time operations. I got a temporal table where current data is stored to work with frecuently, and then a...
11
by: William Buch | last post by:
I have a strange problem. The code isn't written by me, but uses the qsort function in stdlib. ALWAYS, the fourth time through, the memory location of variable list (i.e. mem location = 41813698)...
8
by: Nanda | last post by:
hi, I am trying to generate parameters for the updatecommand at runtime. this.oleDbDeleteCommand1.CommandText=cmdtext; this.oleDbDeleteCommand1.Connection =this.oleDbConnection1;...
4
by: Filippo Pandiani | last post by:
I have a grid that shows the file list from a folder. On the postback, how do I get a Dataset from this grid? Thanks, Filippo.
1
by: Arpan | last post by:
The following ASPX code snippet creates a DataSet programmatically right from the scratch: 'create an empty DataSet Dim objDS As New DataSet("MyDataSet") 'create a new table & add columns Dim...
4
by: andy.mcvicker | last post by:
Hi Gang I have a large VB program that at one point does a lookup to a small table (26 rows by 3 columns). With this table I have to do some counting and retrieval of data. I'm finding that...
3
by: Garth Wells | last post by:
used the following "classic ASP" approach to build a dynamic menu, but would like to know the proper way to implement the same functionality using a .Net technique (e.g., placing the code in the...
38
by: djhulme | last post by:
Hi, I'm using GCC. Please could you tell me, what is the maximum number of array elements that I can create in C, i.e. char* anArray = (char*) calloc( ??MAX?? , sizeof(char) ) ; I've...
32
by: Joe | last post by:
I am just starting to use Object Oriented PHP coding, and I am seeing quite often the following (this example taken from a wiki): $wakka =& new Wakka($wakkaConfig); What exactly is the =&, and...
3
by: barsuk1 | last post by:
Hi there, I have a web page written on PHP. The PHP script itself receives the file uploaded by user, parses it and displays HTML table with the user data - one table row per item. Let's say...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.