public static DataSet GetDataSet(string sql, string tableName)
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
DataSet ds = new DataSet();
try
{
connection.Open();
OleDbDataAdapter command = new OleDbDataAdapter(sql, connection);
command.Fill(ds, "ds");
}
catch (System.Data.OleDb.OleDbException ex)
{
throw new Exception(ex.Message);
}
return ds;
}
}
在access里面执行语句正常,但是就是查询的时候报错
不知如何是好啊,在线等待
解决方案 »
- c#关于汉字替换成字符
- 求解法!
- 求助Stream,FileStream,binarystream,streamreader等等
- 智能客户端发布后的问题 发布以后我修改应用程序的配置文件,客户端连接的时候报错 应用程序验证未成功,无法继续
- 求助:环境问题
- 怎么用其它帐户访问另一个帐户的私有文件夹
- 大家都进来看看吧
- 我在用WebClient向一个网站POST一个字符串,报出这么一个错误,请问高手是什么意思啊?
- 请教高手:在Datagrid中实现下拉列表---------急!!!!!
- 微信公众号与本地SQL数据库连接并推送信息
- C++比较熟的大牛进来下,问个问题啊
- C# 读取移动设备的文件信息。有盘符,只显示WindowsCE。
{
throw new Exception(ex.Message);
}
这个画蛇添足了,应给写为
catch (System.Data.OleDb.OleDbException )
{
throw;
}
当调用函数,运行到command.Fill(ds, "ds");语句时就报错
错误如下:
捕捉到 System.AccessViolationException
Message="尝试读取或写入受保护的内存。这通常指示其他内存已损坏。"
Source="System.Data"
StackTrace:
在 System.Data.Common.UnsafeNativeMethods.ICommandText.Execute(IntPtr pUnkOuter, Guid& riid, tagDBPARAMS pDBParams, IntPtr& pcRowsAffected, Object& ppRowset)
在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForMultpleResults(tagDBPARAMS dbParams, Object& executeResult)
在 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
在 System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
在 System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
在 System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
在 System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
在 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
在试图读写受保护内存时引发的异常。把其他程序关掉看看,不行注销下