編程新手,請儘量協助! 最近,IM負責使用C#& MS訪問來完成一個CRUD窗體窗體應用程序。在Windows窗體中更新CRUD的函數時出錯
在我的更新功能,我面臨以下錯誤之一,我不知道爲什麼.. 我的數據也無法更新。
錯誤:ArgumentException
了未處理
Input string was not in a correct format.Couldn't store in staff_id Column. Expected type is Int32.
這裏是我的代碼:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AcuzioSapp.AcuzioSecureStore_DatabaseDataSetTableAdapters;
namespace AcuzioSapp
{
public partial class Update_Client : Form
{
private DataRow row;
private ClientTableAdapter adapter;
public Update_Client(DataRow row, ClientTableAdapter adapter)
{
InitializeComponent();
this.row = row;
this.adapter = adapter;
textBox_id1.Text = Convert.ToString(row["c_id"]);
textBox_name1.Text = Convert.ToString(row["c_name"]);
textBox_address1.Text = Convert.ToString(row["c_address"]);
textBox_cinfo1.Text = Convert.ToString(row["c_contactinfo"]);
textBox_pinfo1.Text = Convert.ToString(row["profile_info"]);
textBox_refno1.Text = Convert.ToString(row["c_8digitrefno"]);
textBox_staffid1.Text = Convert.ToString(row["staff_id"]);
}
private void button_close_Click(object sender, EventArgs e)
{
Close();
}
private void button_update_Click(object sender, EventArgs e)
{
row["c_name"] = "textBox_name1";
row["c_address"] = "textBox_address1";
row["c_contactinfo"] = "int.Parse(textBox_cinfo1)";
row["c_8digitrefno"] = "(textBox_pinfo1)";
row["profile_info"] = "textBox_refno1";
row["staff_id"] = "int.Parse(textBox_staffid1)";
adapter.Update(row);
}
}
}
讚賞幫助和解釋三江源。
哪條線給你這個錯誤?你調試了你的代碼嗎? –
是的,我做到了。該行[「staff_id」] =「int.Parse(textBox_staffid1)」;和行[「c_contactinfo」] =「int.Parse(textBox_cinfo1)」;線。 –