using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.IO;
namespace csvTOxml
{
class Program
{
static void Main(string[] args)
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\;Extended Properties=\"text;HDR=Yes;FMT=Delimited\"";
OleDbConnection conn = new OleDbConnection(strConn);
OleDbDataAdapter da = default(OleDbDataAdapter);
DataSet ds = new DataSet();
OleDbCommand mycmd = new OleDbCommand("Select * from test.csv", conn);
try
{
da = new OleDbDataAdapter(mycmd);
da.Fill(ds);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return;
}
ds.WriteXml("C:\\CSV.xml");
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.IO;
namespace csvTOxml
{
class Program
{
static void Main(string[] args)
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\;Extended Properties=\"text;HDR=Yes;FMT=Delimited\"";
OleDbConnection conn = new OleDbConnection(strConn);
OleDbDataAdapter da = default(OleDbDataAdapter);
DataSet ds = new DataSet();
OleDbCommand mycmd = new OleDbCommand("Select * from test.csv", conn);
try
{
da = new OleDbDataAdapter(mycmd);
da.Fill(ds);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return;
}
ds.WriteXml("C:\\CSV.xml");
}
}
}
No comments:
Post a Comment