OLEDB连接
Oledbconnection
我正在尝试创建一种方法,让我可以轻松地将 SQL 命令传递到数据库。不过,出于某种原因,我将 运行 保留在这个错误中。
完整的字符串是 Couldn't fetch the required data. Update unable to find TableMapping['tables'] or DataTable 'tables'.
我的数据库方法是这样的:
public void AddToDatabase(string strAccessSelect)
{
Connection();
DataSet myDataSet = new DataSet();
try
{
myAccessConn.Open();
OleDbCommand OleDbUpdateCommand = myAccessConn.CreateCommand();
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();
myDataAdapter.InsertCommand = new OleDbCommand(strAccessSelect, myAccessConn);
myDataAdapter.Update(myDataSet, "tables");
myDataSet.AcceptChanges();
}
catch (Exception ex)
{
error = "Couldn't fetch the required data. " + ex.Message;
}
finally
{
myAccessConn.Close();
}
}
}
我确定我犯了一些非常愚蠢的错误,但我似乎无法弄清楚!希望有人能帮帮我,谢谢!
不完全确定你想做什么,但也许
public void AddToDatabase(string strAccessSelect)
{
try
{
myAccess.Open();
OleDbCommand OleDbUpdateCommand = new OleDbCommand(strAccessSelect, myAccess);
OleDbUpdateCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
error = "Couldn't fetch the required data. " + ex.Message;
}
finally
{
myAccessConn.Close();
}
}
这会有所帮助
删除
http://csharp.net-informations.com/dataadapter/deletecommand-oledb.htm
用于插入
http://csharp.net-informations.com/dataadapter/insertcommand-oledb.htm
上面的其他链接 url 也对您有帮助。
**我没有测试上面显示的代码url。
我正在尝试创建一种方法,让我可以轻松地将 SQL 命令传递到数据库。不过,出于某种原因,我将 运行 保留在这个错误中。 Couldn't fetch the required data. Update unable to find TableMapping['tables'] or DataTable 'tables'.
我的数据库方法是这样的:
public void AddToDatabase(string strAccessSelect)
{
Connection();
DataSet myDataSet = new DataSet();
try
{
myAccessConn.Open();
OleDbCommand OleDbUpdateCommand = myAccessConn.CreateCommand();
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();
myDataAdapter.InsertCommand = new OleDbCommand(strAccessSelect, myAccessConn);
myDataAdapter.Update(myDataSet, "tables");
myDataSet.AcceptChanges();
}
catch (Exception ex)
{
error = "Couldn't fetch the required data. " + ex.Message;
}
finally
{
myAccessConn.Close();
}
}
}
我确定我犯了一些非常愚蠢的错误,但我似乎无法弄清楚!希望有人能帮帮我,谢谢!
不完全确定你想做什么,但也许
public void AddToDatabase(string strAccessSelect)
{
try
{
myAccess.Open();
OleDbCommand OleDbUpdateCommand = new OleDbCommand(strAccessSelect, myAccess);
OleDbUpdateCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
error = "Couldn't fetch the required data. " + ex.Message;
}
finally
{
myAccessConn.Close();
}
}
这会有所帮助
删除 http://csharp.net-informations.com/dataadapter/deletecommand-oledb.htm
用于插入 http://csharp.net-informations.com/dataadapter/insertcommand-oledb.htm
上面的其他链接 url 也对您有帮助。
**我没有测试上面显示的代码url。