首页 新闻 赞助 找找看

从索引0开始,初始化字符串不符合规范。

0
悬赏园豆:10 [待解决问题]

System.ArgumentException
HResult=0x80070057
Message=从索引 0 处开始,初始化字符串的格式不符合规范。
Source=System.Data
StackTrace:
在 System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue)
在 System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey)
在 System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules)
在 System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
在 System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
在 System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
在 System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)
在 System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
在 System.Data.SqlClient.SqlConnection..ctor(String connectionString, SqlCredential credential)
在 System.Data.SqlClient.SqlConnection..ctor(String connectionString)
在 登录界面.DBHelper.Updata(String str) 在 C:\Users\李三缄\source\repos\登录界面\登录界面\DBHelper.cs 中: 第 19 行
在 登录界面.购票界面.button1_Click(Object sender, EventArgs e) 在 C:\Users\李三缄\source\repos\登录界面\登录界面\购票界面.cs 中: 第 129 行
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.RunDialog(Form form)
在 System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
在 System.Windows.Forms.Form.ShowDialog()
在 登录界面.Form5.button7_Click(Object sender, EventArgs e) 在 C:\Users\李三缄\source\repos\登录界面\登录界面\主页.cs 中: 第 59 行
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.RunDialog(Form form)
在 System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
在 System.Windows.Forms.Form.ShowDialog()
在 登录界面.Form1.button2_Click(Object sender, EventArgs e) 在 C:\Users\李三缄\source\repos\登录界面\登录界面\用户登录.cs 中: 第 112 行
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 登录界面.Program.Main() 在 C:\Users\李三缄\source\repos\登录界面\登录界面\Program.cs 中: 第 26 行

此异常最初是在此调用堆栈中引发的:
[外部代码]
登录界面.DBHelper.Updata(string) (位于 DBHelper.cs 中)
登录界面.购票界面.button1_Click(object, System.EventArgs) (位于 购票界面.cs 中)
[外部代码]
登录界面.Form5.button7_Click(object, System.EventArgs) (位于 主页.cs 中)
[外部代码]
登录界面.Form1.button2_Click(object, System.EventArgs) (位于 用户登录.cs 中)
[外部代码]
登录界面.Program.Main() (位于 Program.cs 中)

C#
李三缄的主页 李三缄 | 初学一级 | 园豆:192
提问于:2021-09-07 06:32

打断点调试,你发这有啥用?问题都告诉你了“ 从索引 0 处开始,初始化字符串的格式不符合规范。”

唉我干啥啊 2年前

@唉我干啥啊: “conn.ServerVersion”引发了类型“System.InvalidOperationException”的异常

李三缄 2年前

@李三缄: 你数据库是不是没连上?

唉我干啥啊 2年前

@唉我干啥啊: 连接了

李三缄 2年前

@李三缄: 能取到值吗?

唉我干啥啊 2年前

@唉我干啥啊: 可以了

李三缄 2年前
< >
分享
所有回答(2)
0

是连接字符串有问题,你将数据库的连接字符串格式发出来看看

lyj等待 | 园豆:220 (菜鸟二级) | 2021-09-09 09:53
0

只有异常 代码截图呢

丿如何是好 | 园豆:226 (菜鸟二级) | 2021-09-17 14:46
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册