我创建了一个软件,它在 Visual Studio 中运行良好。但是当我将它部署在任何计算机上时,它在尝试连接到数据库时会出现以下错误:-
************** Exception Text **************
System.InvalidOperationException: The ConnectionString property has not been initialized.
at System.Data.SqlClient.SqlConnection.PermissionDemand()
at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at DentalGood.frmLogin.startLogin() in E:\PRGS\DentalGood\DentalGood\frmLogin.cs:line 28
at KryptonForm.frmMain.btnLogin_Click(Object sender, EventArgs e) in E:\PRGS\DentalGood\DentalGood\frmMain.cs:line 216
at ComponentFactory.Krypton.Ribbon.KryptonRibbonGroupButton.OnClick(EventHandler finishDelegate)
at ComponentFactory.Krypton.Ribbon.KryptonRibbonGroupButton.PerformClick(EventHandler finishDelegate)
at a5.d(Object A_0, EventArgs A_1)
at eq.b(Object A_0, EventArgs A_1)
at ek.b(EventArgs A_0)
at ek.a(Control A_0, Point A_1, MouseButtons A_2)
at ComponentFactory.Krypton.Toolkit.ToolTipController.MouseUp(Control c, Point pt, MouseButtons button)
at ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button)
at ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button)
at ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button)
at ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button)
at ComponentFactory.Krypton.Toolkit.ViewManager.MouseUp(MouseEventArgs e, Point rawPt)
at ComponentFactory.Krypton.Toolkit.ViewControl.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at ComponentFactory.Krypton.Toolkit.ViewControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.6400 (Win8RTMGDR.050727-6400)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
已经在 program.cs 文件中初始化了 ConnectionString。它将连接字符串存储在一个文件中,并在需要连接时加载它。有什么帮助吗?