M
mj
Hi All,
I am uploading and reading CSV files in my web application. But it is
behaving weired. Sometimes it reads values and sometimes it just
rejects them.
My Connection Code is:
System.Data.OleDb.OleDbConnection myConnection = new
System.Data.OleDb.OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source="+System.Web.HttpContext.Current.Request.MapPath("upload/")+";"+
"Extended Properties=\"text;\"");
System.Data.OleDb.OleDbDataAdapter myAdapter = new
System.Data.OleDb.OleDbDataAdapter("SELECT * FROM " +
Session["FileName"] + ".csv", myConnection);
DataSet mySet = new DataSet(Session["FileName"] + ".csv");
myAdapter.Fill(mySet, Session["FileName"] + ".csv");
DataTable myTable = mySet.Tables[Session["FileName"] + ".csv"];
foreach (DataRow myRow in myTable.Rows)
{
SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings["sqlConnString"],
"UpdateWithDBByIDAndOrder",
Convert.ToString(myRow[0]), Session["FileName"], myRow[1].ToString());
}
uploadmessage.Text = "File Uploaded Successfully";
The File format is:
ID,Order
9806830X,NEX
2828255U,51
2828250X,80
2828259B,73
2828258P,56
3000585,56
3182875,76
2487424E,70
Sometimes - it reads the file with all Alpha ID, Sometimes it reads
the file with all Numeric (3...) ID's, Sometimes it reads all and
sometimes it doesn't read anything. I have tried checking the value
read and that is NULL.
Can anyone Please help me with this. Anyhelp would be good.
Thanks,
Mj
I am uploading and reading CSV files in my web application. But it is
behaving weired. Sometimes it reads values and sometimes it just
rejects them.
My Connection Code is:
System.Data.OleDb.OleDbConnection myConnection = new
System.Data.OleDb.OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source="+System.Web.HttpContext.Current.Request.MapPath("upload/")+";"+
"Extended Properties=\"text;\"");
System.Data.OleDb.OleDbDataAdapter myAdapter = new
System.Data.OleDb.OleDbDataAdapter("SELECT * FROM " +
Session["FileName"] + ".csv", myConnection);
DataSet mySet = new DataSet(Session["FileName"] + ".csv");
myAdapter.Fill(mySet, Session["FileName"] + ".csv");
DataTable myTable = mySet.Tables[Session["FileName"] + ".csv"];
foreach (DataRow myRow in myTable.Rows)
{
SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings["sqlConnString"],
"UpdateWithDBByIDAndOrder",
Convert.ToString(myRow[0]), Session["FileName"], myRow[1].ToString());
}
uploadmessage.Text = "File Uploaded Successfully";
The File format is:
ID,Order
9806830X,NEX
2828255U,51
2828250X,80
2828259B,73
2828258P,56
3000585,56
3182875,76
2487424E,70
Sometimes - it reads the file with all Alpha ID, Sometimes it reads
the file with all Numeric (3...) ID's, Sometimes it reads all and
sometimes it doesn't read anything. I have tried checking the value
read and that is NULL.
Can anyone Please help me with this. Anyhelp would be good.
Thanks,
Mj