| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3947 人关注过本帖
标题:尝试读取或写入受保护的内存
只看楼主 加入收藏
sliang28
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2013-5-15
收藏
 问题点数:0 回复次数:1 
尝试读取或写入受保护的内存
各位老师:
下面函数可以正常调用2次,第三次调用的时候就出现了"尝试读取或写入受保护的内存"的错误,SQL语句只是换了变量而已,在数据库中sql多次查询都是正常的,请老师分析是什么问题造成的.谢谢!
OdbcCommand cmd = new OdbcCommand();
             = commandText;
             = type;
            cmd.Connection = Conn;
            OdbcDataAdapter dr = new OdbcDataAdapter(cmd);
            DataTable dt = new DataTable();
            dr.Fill(dt);
            cmd.Connection.Close();
            return dt;
搜索更多相关主题的帖子: 数据库 
2016-02-03 10:37
sliang28
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2013-5-15
收藏
得分:0 
异常的详细信息如下:
程序代码:
未处理System.AccessViolationException
  Message=尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
  Source=System.Data
  StackTrace:
       在 System.(OdbcStatementHandle StatementHandle, Int16 ColumnNumber, Int16 FieldIdentifier, CNativeBuffer CharacterAttribute, Int16 BufferLength, Int16& StringLength, IntPtr& NumericAttribute)
       在 System.Data.Odbc.OdbcStatementHandle.ColumnAttribute(Int32 columnNumber, Int16 fieldIdentifier, CNativeBuffer characterAttribute, Int16& stringLength, SQLLEN& numericAttribute)
       在 System.Data.Odbc.OdbcDataReader.GetColAttributeStr(Int32 i, SQL_DESC v3FieldId, SQL_COLUMN v2FieldId, HANDLER handler)
       在 System.Data.Odbc.OdbcDataReader.GetName(Int32 i)
       在 System.Data.ProviderBase.SchemaMapping.GenerateFieldNames(DataReaderContainer dataReader)
       在 System.Data.ProviderBase.SchemaMapping..ctor(DataAdapter adapter, DataSet dataset, DataTable datatable, DataReaderContainer dataReader, Boolean keyInfo, SchemaType schemaType, String sourceTableName, Boolean gettingData, DataColumn parentChapterColumn, Object parentChapterValue)
       在 System.(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 schemaCount, DataColumn parentChapterColumn, Object parentChapterValue)
       在 System.(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 schemaCount, DataColumn parentChapterColumn, Object parentChapterValue)
       在 System.(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
       在 System.(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
       在 System.(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       在 System.(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
       在 System.(DataTable dataTable)
       在 WindowsFormsApplication1.Form1.txtLot_KeyPress(Object sender, KeyPressEventArgs e) 位置 c:\Users\1510014\Desktop\副本\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs:行号 34
       在 System.Windows.Forms.Control.OnKeyPress(KeyPressEventArgs e)
       在 System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
       在 System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
       在 System.Windows.Forms.Control.WmKeyChar(Message& m)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.TextBoxBase.WndProc(Message& m)
       在 System.Windows.Forms.TextBox.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       在 System.Windows.Forms.(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.Run(Form mainForm)
       在 WindowsFormsApplication1.Program.Main() 位置 c:\Users\1510014\Desktop\副本\WindowsFormsApplication1\WindowsFormsApplication1\Program.cs:行号 18
  InnerException: 
2016-02-03 10:47
快速回复:尝试读取或写入受保护的内存
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024118 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved