我在c#中创建了一个测验应用程序。
我创建了一个本地数据库。当我在我的电脑上发出命令
sqllocal info
它显示了我的数据库。它在同一台PC上工作正常。但是当我安装我的应用程序时,我得到以下错误:
但是当我在其他电脑上运行相同的应用程序时,它会给我错误
有关调用实时的详细信息,请参阅此消息的结尾 (JIT)调试而不是此对话框。
**************异常文本************** System.Data.SqlClient.SqlException(0x80131904):网络相关或 建立连接时发生特定于实例的错误 SQL Server。服务器未找到或无法访问。校验 实例名称正确且SQL Server配置为 允许远程连接。 (提供者:SQL网络接口,错误:52 - 无法找到本地数据库运行时安装。验证是否已正确安装SQL Server Express以及本地数据库 运行时功能已启用。)---> System.ComponentModel.Win32Exception (0x80004005):系统找不到指定的文件 System.Data.SqlClient.SqlInternalConnection.OnError(SQLEXCEPTION exception,Boolean breakConnection,Action
1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource
1 retry,DbConnectionOptions userOptions,DbConnectionInternal&连接) System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(的DbConnection owningConnection,TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1次重试,DbConnectionOptions userOptions)at at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(的DbConnection outerConnection,DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource
1 重试) System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 重试)在System.Data.SqlClient.SqlConnection.Open()处 System.Data.Common.DbDataAdapter.FillInternal(DataSet数据集, DataTable [] datatables,Int32 startRecord,Int32 maxRecords,String srcTable,IDbCommand命令,CommandBehavior行为)at System.Data.Common.DbDataAdapter.Fill(DataTable [] dataTables,Int32 startRecord,Int32 maxRecords,IDbCommand命令,CommandBehavior 在System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)at MITCOE.TestDataSetTableAdapters.TableTableAdapter.Fill(TableDataTable dataTable)在MITCOE.Form2.Form2_Load(对象发送者,EventArgs e)
在System.Windows.Forms.Form.OnLoad(EventArgs e)at System.Windows.Forms.Form.OnCreateControl()at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
在System.Windows.Forms.Control.CreateControl()at System.Windows.Forms.Control.WmShowWindow(Message& m)at System.Windows.Forms.Control.WndProc(Message& m)at System.Windows.Forms.ScrollableControl.WndProc(Message& m)at System.Windows.Forms.ContainerControl.WndProc(Message& m)at System.Windows.Forms.Form.WmShowWindow(Message& m)at System.Windows.Forms.Form.WndProc(Message& m)at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32) msg,IntPtr wparam,IntPtr lparam) ClientConnectionId:00000000-0000-0000-0000-000000000000错误 号:2,状态:0,类别:20当我写sqllocal信息时,它给了我
' sqllocal'不被视为内部或外部命令, 可操作程序或批处理文件。
那么为什么我的localdb不能在其他PC上运行
答案 0 :(得分:0)
您需要在已安装的PC上安装sqlexpress,或者您可以在应用程序中包含sql lite并在首次运行时显示该位置。