SQL2KDBA69
Programmer
im trying to import a xml file into my database. this is my code
here is error i get :
{System.InvalidOperationException: Update unable to find TableMapping['Servers'] or DataTable 'Servers'.
Code:
if (ofdServers.ShowDialog() == DialogResult.OK)
{
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Remote\\Serverlist.mdb");
conn.Open();
OleDbDataAdapter da = new OleDbDataAdapter("Select * from Servers",conn);
DataRow dr;
DataSet ds = new DataSet();
da.Fill(ds);
ds.Clear();
ds.ReadXml(ofdServers.FileName);
int dsrowcount = ds.Tables[0].Rows.Count;
try
{
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < dsrowcount; i++)
{
dr = ds.Tables[0].NewRow();
dr["ipaddress"] = ds.Tables[0].Rows[i]["ipaddress"].ToString();
dr["admin_port"] = ds.Tables[0].Rows[i]["admin_port"].ToString();
dr["n4admin_password"] = ds.Tables[0].Rows[i]["n4admin_password"].ToString();
dr["Web_Console"] = ds.Tables[0].Rows[i]["web_console"].ToString();
ds.Tables[0].Rows.Add(dr);
}
da.Update(ds, "Servers");
LoadTree();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Import Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
finally
{
conn.Close();
conn.Dispose();
}
}
here is error i get :
{System.InvalidOperationException: Update unable to find TableMapping['Servers'] or DataTable 'Servers'.