访问冲突异常未处理 [英] Access Violation Exception was unhandled

查看:99
本文介绍了访问冲突异常未处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



访问冲突错误,我在Windows XP PC上试过并且我没有遇到任何问题,他们也使用相同的MS Access 2010数据库,但在Windows 07中,我得到了。



是的我通过OLEDB连接,是客户需要在MS Access 2010或更高版本中开发的应用程序...



当我点击按钮执行数据库查询时出现问题...



 < span class =code-keyword> private   void  cmbBox_SelectedIndexChanged( object  sender,EventArgs e )
{
if (cmbBox.SelectedItem!= null
{
ProcessTreeData(cmbBox.SelectedItem.ToString(),treePane);
}
}

public void ProcessTreeData( string projectName,TreeView视图)
{
string query = 从Project中选择ID,VisibleName,其中InternalName =' + projectName + ';
MessageBox.Show(query);
// 以下行代码执行时会出现问题......

DataTable project_tble = new DataTable();
project_tble = dbCon.GetValuesFromDatabaseInTable(query);
}





[edit]已添加代码块和列表[/ edit]

解决方案

不要将数据库文件存储在应用程序的安装文件夹中。一个非管理用户不能在那里写(当他在数据库中更新数据时,他写道!) - 从Vista开始,Microsoft强制执行这个概念。将您的数据库放到它所属的文件夹中,例如%PROGRAMDATA%\Your Company \Your Software \SomeDatabase.mdb


解决方案2不是解决方案。这真是一件非常危险的事情。如果装载需要更多时间,你会怎么做?

这比没有解决方案更糟糕。你开始欺骗自己了。我想你不明白为什么你的修复有效,对你来说,它足以让它以某种方式运作。这是工程师可能遇到的最糟糕的事情。



您没有提供完全解决问题的信息,但一种可能的解决方案是覆盖 Form.OnShown 或处理事件 Form.Shown

http://msdn.microsoft.com/en-us/library/system .windows.forms.form.onshown%28v = vs.110%29.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system。 windows.forms.form.shown(v = vs.110).aspx [ ^ ]。



- SA

Hi all,

Access Violation Error, I have tried in Windows XP PC and I don't get any issue, they are also using the same MS Access 2010 Database, But in Windows 07 I get.

Yes I am connecting via OLEDB, yes customer needs the application to be developed in MS Access 2010 or higher...

The problem occurs, when I click on the button, which executes the database Query...

private void cmbBox_SelectedIndexChanged(object sender, EventArgs e) 
{ 
   if (cmbBox.SelectedItem != null) 
   { 
      ProcessTreeData(cmbBox.SelectedItem.ToString(), treePane); 
   } 
} 

public void ProcessTreeData(string projectName, TreeView view) 
{ 
   string query = "select ID, VisibleName from Project where InternalName ='" + projectName + "'"; 
   MessageBox.Show(query); 
   // Issues occurs when below line code executes...

   DataTable project_tble = new DataTable(); 
   project_tble = dbCon.GetValuesFromDatabaseInTable(query);
}



[edit]Code block and tabulation added[/edit]

解决方案

Do not store the database files in the installation folder of your application. A non-administrative user must not write there (and when updating data in the database, he writes!) - starting from Vista, Microsoft enforces that concept. Put your database to a folder where it belongs to, e.g. %PROGRAMDATA%\Your Company\Your Software\SomeDatabase.mdb


Solution 2 is not a solution. This is really bad dangerous thing. What if loading will need a bit more time, what would you do?
This is worse than no solution at all. You are starting to fool yourself. I think you don't understand why your "fix" worked, for you, it's enough that it works somehow. This is the worst thing which can happen to an engineer.

You did not provide information to solve it exactly, but one possible solution would be to override Form.OnShown or handling the event Form.Shown:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.onshown%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.shown(v=vs.110).aspx[^].

—SA


这篇关于访问冲突异常未处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆