0
我完成程序並開始工作後,我用sql數據庫做了一個C#程序,
我想將其中一個列類型從int更改爲nvarchar(50),知道數據庫已經充滿了數據。如何更改Visual Studio中的SQL列類型C#
我將表列類型更改爲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)
謝謝。
UPDATE:其實點擊保存按鈕
這裏當異常上升的方法
private void medicinTableBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
{
this.Validate();
this.medicinTableBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.tiryaqDatabaseDataSet);
}
}
你刷新了數據集嗎? 'TiryaqDatabaseDataSet'? – 2013-04-04 01:47:50
我不確定,怎麼做? – 2013-04-04 01:48:42
嘗試打開它並右鍵單擊打開區域的某處,查看是否有刷新模式的選項。 – 2013-04-04 01:49:57