Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

Creating an in memory table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
HinduNationalist@gmail.com - 25 Oct 2007 22:36 GMT
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.
Nicholas Paldino [.NET/C# MVP] - 25 Oct 2007 22:55 GMT
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.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

>I have the following Test.CSV file:
> Col1,Col2,Col3
[quoted text clipped - 20 lines]
>
> But I want to just have selected values into dt.
HinduNationalist@gmail.com - 26 Oct 2007 03:46 GMT
On Oct 26, 2:55 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.com> wrote:
>     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.
Nicholas Paldino [.NET/C# MVP] - 26 Oct 2007 15:35 GMT
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.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> On Oct 26, 2:55 am, "Nicholas Paldino [.NET/C# MVP]"
> <m...@spam.guard.caspershouse.com> wrote:
[quoted text clipped - 10 lines]
>
> -Thanks.
HinduNationalist@gmail.com - 26 Oct 2007 18:04 GMT
On Oct 26, 7:35 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.com> wrote:
>     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.
Nicholas Paldino [.NET/C# MVP] - 26 Oct 2007 19:52 GMT
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.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> On Oct 26, 7:35 pm, "Nicholas Paldino [.NET/C# MVP]"
> <m...@spam.guard.caspershouse.com> wrote:
[quoted text clipped - 4 lines]
> Thanks for reply.
> I had already tried it. In OleDb it doesn't work.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.