调试的时候突然之间一连数据库就崩, 结果把连接单拉出来试试还是不行.我查了一下都说是代码的问题,可是我单独就写一句连接还是报错,不知道怎么解决,向大神求助啊!!!
代码就这一块
SqlConnection con = new SqlConnection("Data Source=192.168.***.***;Initial Catalog=******;Password=***;Persist Security Info=FALSE;User ID=***");
try
{
con.Open();
}
“System.AccessViolationException”类型的未经处理的异常在 System.Data.dll 中发生
其他信息: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
StackTrace:
在 SNINativeMethodWrapper.SNIClose(IntPtr pConn)
在 System.Data.SqlClient.SNIHandle.ReleaseHandle()
在 System.Runtime.InteropServices.SafeHandle.InternalDispose()
在 System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
在 System.Runtime.InteropServices.SafeHandle.Dispose()
在 System.Data.SqlClient.TdsParserStateObject.Dispose()
在 System.Data.SqlClient.TdsParser.Disconnect()
在 System.Data.SqlClient.SqlInternalConnectionTds.LoginFailure()
在 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
重启一下sql 服务试试
安装过Visual Studio 2013 beta版本的吧。