我用 sql 数据库制作了一个 C# 程序,
在完成程序并开始处理它之后,我想将其中一个列类型从 int 更改为 nvarchar(50),因为我知道数据库已经填充了数据。
我将表列类型更改为 nvarchar(50),并将其在数据集上也更改为 System.String。
运行程序后,它给了我这个异常
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.FormatException: Failed to convert parameter value from a String to a Int32. ---> System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType, Boolean& coercedToDataFeed, Boolean& typeChanged, Boolean allowStreaming)
--- End of inner exception stack trace ---
at Tiryaq.TiryaqDatabaseDataSetTableAdapters.TableAdapterManager.UpdateAll(TiryaqDatabaseDataSet dataSet) in C:\Users\Firas\Documents\Visual Studio 2010\Projects\Tiryaq\Tiryaq\TiryaqDatabaseDataSet.Designer.cs:line 1973
at Tiryaq.Form1.medicinTableBindingNavigatorSaveItem_Click(Object sender, EventArgs e) in C:\Users\Firas\Documents\Visual Studio 2010\Projects\Tiryaq\Tiryaq\Form1.cs:line 31
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
谢谢你。
更新:实际上点击保存按钮时异常上升
是方法
private void medicinTableBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
{
this.Validate();
this.medicinTableBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.tiryaqDatabaseDataSet);
}
}