Click here to Skip to main content
15,867,835 members
Home / Discussions / C#
   

C#

 
GeneralRe: Am I being dense? Pin
SpudgunDoogal7-Jul-03 22:47
SpudgunDoogal7-Jul-03 22:47 
GeneralRe: Am I being dense? Pin
SpudgunDoogal8-Jul-03 1:14
SpudgunDoogal8-Jul-03 1:14 
GeneralRe: Am I being dense? Pin
Daniel Turini8-Jul-03 2:03
Daniel Turini8-Jul-03 2:03 
GeneralDataSet -> Comma/Tab delimited Pin
dratti7-Jul-03 5:36
dratti7-Jul-03 5:36 
GeneralRe: DataSet -> Comma/Tab delimited Pin
Heath Stewart7-Jul-03 9:48
protectorHeath Stewart7-Jul-03 9:48 
GeneralRe: DataSet -> Comma/Tab delimited Pin
dratti7-Jul-03 10:51
dratti7-Jul-03 10:51 
GeneralRe: DataSet -> Comma/Tab delimited Pin
leppie7-Jul-03 14:39
leppie7-Jul-03 14:39 
GeneralRe: DataSet -> Comma/Tab delimited Pin
MrEyes11-Jul-03 5:33
MrEyes11-Jul-03 5:33 
By now you have probably already solved this problem, but just incase you havent I recently put the following code together to read a file as a dataset and vice versa :

//read CSV format files into a dataset
public static DataSet ReadFileAsDataSet(string filePath, string fileName)
{
  OleDbConnection oCon = new OleDbConnection(
    "Provider=Microsoft.Jet.OLEDB.4.0;" +
	"Data Source=" + filePath + ";" +
	"Extended Properties=\"text;HDR=NO;FMT=Delimited\"");

	OleDbDataAdapter oCmd = new OleDbDataAdapter(
	  "select * from "+fileName, oCon);

  DataSet ds = new DataSet();
  oCmd.Fill(ds);
  oCon.Close();
			
  return ds;
}

//write a dataset as a file (currently only supports one table)
//produces files with the following format - "val","val","val","val"
public static void WriteDataSetAsFile(string filepath, string fileName, DataSet ds)
{
  if(File.Exists(filepath + "\\" + fileName))
    File.Delete(filepath + "\\" + fileName);

  StreamWriter sw = new StreamWriter(filepath + "\\" + fileName, true);

  foreach (DataRow dr in ds.Tables[0].Rows)
  {
    object[] objRowData = dr.ItemArray;
    string strRowData = string.Empty;
    foreach(object obj in objRowData)
    {
      strRowData+= "\"" + obj.ToString() + "\",";
    }
    strRowData = strRowData.Remove(strRowData.Length - 1, 1);
    sw.WriteLine(strRowData);
  }
  sw.Close();
}

GeneralRe: DataSet -> Comma/Tab delimited Pin
Anonymous11-Jul-03 11:22
Anonymous11-Jul-03 11:22 
Generalgrid control Pin
retZ7-Jul-03 4:50
retZ7-Jul-03 4:50 
GeneralRe: grid control Pin
Not Active7-Jul-03 6:08
mentorNot Active7-Jul-03 6:08 
GeneralRe: grid control Pin
retZ7-Jul-03 11:01
retZ7-Jul-03 11:01 
GeneralNeed to Export Records to Remote Terminal Pin
Leon van Wyk7-Jul-03 4:04
professionalLeon van Wyk7-Jul-03 4:04 
GeneralRe: Need to Export Records to Remote Terminal Pin
Heath Stewart7-Jul-03 10:01
protectorHeath Stewart7-Jul-03 10:01 
GeneralRe: Need to Export Records to Remote Terminal Pin
leppie7-Jul-03 16:20
leppie7-Jul-03 16:20 
GeneralAdding to a dataTable Pin
totig7-Jul-03 3:33
totig7-Jul-03 3:33 
GeneralRe: Adding to a dataTable Pin
perlmunger7-Jul-03 11:28
perlmunger7-Jul-03 11:28 
Generalcomponent configuration. Pin
Darkmatter7-Jul-03 3:20
Darkmatter7-Jul-03 3:20 
GeneralRe: component configuration. Pin
perlmunger7-Jul-03 11:43
perlmunger7-Jul-03 11:43 
GeneralWriting to the Output | Debug window Pin
albean7-Jul-03 2:51
albean7-Jul-03 2:51 
GeneralRe: Writing to the Output | Debug window Pin
Roland Bär7-Jul-03 3:13
Roland Bär7-Jul-03 3:13 
GeneralCrystal Reports 'Command' SetDataSource Pin
krisp7-Jul-03 1:49
krisp7-Jul-03 1:49 
GeneralArrays Pin
_cancer_7-Jul-03 1:21
_cancer_7-Jul-03 1:21 
GeneralRe: Arrays Pin
perlmunger7-Jul-03 11:58
perlmunger7-Jul-03 11:58 
GeneralRe: Arrays Pin
PeterMoon29-Jan-08 17:53
PeterMoon29-Jan-08 17:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.