G
Guest
Hi!
I have text file with tabbed columns, I am getting those values into a
dataset by parsing the tab. I want to save the same dataset into a table in a
database. I am getting error "Update requires a valid InsertCommand when
passed DataRow collection with new rows". I am using the following code
StreamReader s = new StreamReader(File);
string AllData = s.ReadToEnd();
string[] rows = AllData.Split("\r\n".ToCharArray());
//Now add each row to the DataSet
foreach (string r in rows)
{
//Split the row at the delimiter.
if (r != "")
{
string[] items = r.Split(delimiter.ToCharArray());
//Add the item
result.Tables[TableName].Rows.Add(items);
}
}
Database dbName = DatabaseFactory.CreateDatabase();
DbDataAdapter da = dbName.GetDataAdapter();
da.Update(result, "ProductsTest");
Thanks in advance.
Regards,
Bareb
I have text file with tabbed columns, I am getting those values into a
dataset by parsing the tab. I want to save the same dataset into a table in a
database. I am getting error "Update requires a valid InsertCommand when
passed DataRow collection with new rows". I am using the following code
StreamReader s = new StreamReader(File);
string AllData = s.ReadToEnd();
string[] rows = AllData.Split("\r\n".ToCharArray());
//Now add each row to the DataSet
foreach (string r in rows)
{
//Split the row at the delimiter.
if (r != "")
{
string[] items = r.Split(delimiter.ToCharArray());
//Add the item
result.Tables[TableName].Rows.Add(items);
}
}
Database dbName = DatabaseFactory.CreateDatabase();
DbDataAdapter da = dbName.GetDataAdapter();
da.Update(result, "ProductsTest");
Thanks in advance.
Regards,
Bareb