我用VS2013做了一个软件,它有一个用MSSQL2014写的数据库。当我在我的PC上运行它时(我的OC操作系统是windows-7 64位),软件工作正常(如果数据库在我的PC上或本地网络中的其他PC上),但当我想在其他PC上运行它时(特别是一些安装了windows-7 32位的PC,当它想要连接到数据库时就会有问题-当它想要加载表单时就没有问题)。
SqlConnection sqlConnection1 = new sqlConnection("Server=192.168.100.18;Database=test;User Id=sa;Password=111;");
SqlCommand cmd = new SqlCommand();
SqlDataReader reader;
cmd.CommandText = "SELECT * FROM test";
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
reader = cmd.ExecuteReader();
sqlConnection1.Close();
MessageBox.Show("Ok");当程序运行时,代码sqlConnection1.Open();要执行它时出现错误:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt但它在本地网络中其他PC上工作正常
发布于 2015-06-09 15:43:04
幸运的是,我可以发现问题。.NET FrameWork 4.5.1版有一个问题。我将版本改为4或4.5,问题就解决了
https://stackoverflow.com/questions/30724089
复制相似问题