我有三个文本框,用于电话号码手机号码和年龄; 我在那里输入详细信息并将其插入数据库。插入后如何清除文本框。它不会允许我这样做因为插入方法就像这样
public void insert(int mobile,int telephone,int age)
{
try
{
MySqlConnection asp= new MySqlConnection(conString);
asp.Open();
string insertString = "insert into users(mob,tele,age) values('"+mobile+"','"+telephone+"','"+age+"')
MySqlCommand cmd = new MySqlCommand(insertString,asp);
dr = cmd.ExecuteReader();
MessageBox.Show("New user added succesfully","Information");
//afteer this how to empty the three textboxes
// ihave used these three as integers in database
}
调用方法是
insert(int.parse(textbox1text),int.parse(textbox2.text),int.parse(textbox3.text))
答案 0 :(得分:0)
您可以使用TextBox.Clear()方法清除TextBox
声明后Insert()
的内容
试试这个:
insert(int.parse(textbox1.Text),int.parse(textbox2.Text),int.parse(textbox3.Text));
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
答案 1 :(得分:0)
调用插入方法后,请使用此
insert(int.parse(textbox1text),int.parse(textbox2.text),int.parse(textbox3.text));
textBox1.Text =String.Empty;
textBox2.Text =String.Empty;
textBox3.Text =String.Empty;
(或)
insert(int.parse(textbox1text),int.parse(textbox2.text),int.parse(textbox3.text));
textBox1.Text ="";
textBox2.Text ="";
textBox3.Text ="";