473,804 Members | 3,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

import file in dataset problem

Hi

I try to import file in a dataset. How I can do this ?
Jul 21 '05 #1
2 3481
Hi ERic,
Hi

I try to import file in a dataset. How I can do this ?


First you need a DataTable to put the stuff in. If you want to import a
CSV-file, you can separate the different items using the
String.Split()-method. For example (from scratch):
=============== =============== =
// Create dynamic Table
DataTable dt = new DataTable();

// Create Row Data - in this case 3 columns which means
// That in your CSV-file are also only 3 items per row
dt.Columns.Add( "ComputerID ", System.Type.Get Type("System.St ring"));
dt.Columns.Add( "Computerna me", System.Type.Get Type("System.St ring"));
dt.Columns.Add( "Active", System.Type.Get Type("System.St ring"));

// Read the Textfile
StreamReader sr = new StreamReader(yo urfilename);

string datStr;
do {
datStr = sr.ReadLine();
if ( datStr != null ) {
string[] rowData = sr.Split(',');

// CreateRow
DataRow dr = dt.NewRow();
// Fill Row
dr["ComputerID "] = rowData[0];
dr["Computerna me"] = rowData[1];
dr["Active"] = rowData[2];
// Add Row
dt.Rows.Add( dr );
}
} while ( datStr != null );

DataSet ds = new DataSet();
// Insert Table
ds.Tables.Add( dt );

=============== =============== =

Remember, this is not proved, I just wrote it down from scratch ... but this
is the way to go, I suppose.

Regards,

--
Frank Eller [.NET MVP]
www.frankeller.de
..NET Developers Group Munich- www.munichdot.net
Jul 21 '05 #2
see my other reply to your similar query in this same newsgroup.

"Eric Caron" <ec****@pgsyste m.com> wrote in message
news:av******** *************** *********@4ax.c om...
Hi

I try to import file in a dataset. How I can do this ?

Jul 21 '05 #3

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

Similar topics

1
2689
by: Ed Bacon | last post by:
I am trying to produce a generic "audit report" for various transactions in our application. Each transaction type defines a document (and has an associated schema). When a transaction leads to a "write to the database", we store the dataset's diffgram in the audit table. To render the audit report we load the diffgram into a generic DataSet and bind it to a grid. All works well unless the document's schema had an <xs:import> to bring...
2
7981
by: Ghost | last post by:
Hello. What is the optimal way to manualy import/export data from/to XML file to/form my DataSet? What I wnat: 1. To add some data (records) from XML file to may dataset. 2.. To add some data (records) from dataset to may XML file. For example:
3
2711
by: Schultz | last post by:
I would like to know if it is possible to import data from MS Excel 2000 to a dataset using asp.net. The excel file would need to be uploaded to the server from a web page first, before the loaded into a dataset. After the data is stored in the dataset, i would need to write the information to an access db. If it is possible to do this, where can I find help on how to import excel data to a dataset? Thanks!
0
2366
by: Locusta | last post by:
Hello, I'm looking for a generic way to import XML documents into a local SQLCE database (on Pocket PC). To complicate, the local SQLCE database has more fields in the tables than the XML document has nodes, and I would like to have a generic tool (I need to import about 35 tables). I'm trying something below:
7
2384
by: Joe Fallon | last post by:
I am importing a delimited ASCII text file into a dataset using OLEDB. I set up the connection and dataadapter and then fill the dataset. It works - sort of. It turns out that some of my data is omitted. Specifically, one of the columns is set to Int32, but the data is really string. The first few rows of data have numeric valus in this field but further down there are some letters mixed in with the numbers. So only fields with pure...
2
204
by: Eric Caron | last post by:
Hi I try to import file in a dataset. How I can do this ?
4
3977
by: BostonNole | last post by:
I am looking for suggestions on the most efficient way to import 7 different fixed width files into a DataSet. Not all at the same time. One file at a time, but the format could change from file to file. I have 7 (and more coming) different fixed width files that my clients provide to me, within each one the field sizes and ordering is slightly different...maddening I know. Each file could possibly be as large as 150 MG with around...
1
2116
by: The_Fakir_42 | last post by:
Hi, I have a very tricky problem... I import an XLS file from my asp web application; this xls file contains lots of single-cell named areas. Usually, I know how to get them, this way : ' Create temporary dataset Dim ds As New DataSet
7
12079
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
0
9576
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,...
0
10323
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10074
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...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
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
6847
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
5516
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...
1
4292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2988
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.