62,268
社区成员
发帖
与我相关
我的任务
分享
protected void Button2_Click1(object sender, EventArgs e)
{
string strsql = "insert into phone(ID,name,department,possition,internal,telephone,[in-fax],[out-fax],[e-mail]) values(" + TextBox3.Text + ",'" + TextBox4.Text + "'" +
" '" + TextBox5.Text + "', '" + TextBox1.Text + "', '" + TextBox2.Text + "', '" + TextBox6.Text + "'"+
"'" + TextBox7.Text + "', '" + TextBox8.Text + "', '" + TextBox9.Text + "' )";
SqlCommand InsertCommand = new SqlCommand(strsql,conn);
conn.Open();
int i = InsertCommand.ExecuteNonQuery();
if(i>0)
{
}else
{
}
conn.Close();
protected void Button2_Click1(object sender, EventArgs e)
{
SqlCommand InsertCommand = new SqlCommand();
InsertCommand.Connection = conn;
InsertCommand.CommandType = CommandType.Text;
InsertCommand.CommandText = "insert into phone(ID,name,department,possition,internal,telephone,[in-fax],[out-fax],[e-mail]) values(" + TextBox3.Text + ",'" + TextBox4.Text + "'" +
" '" + TextBox5.Text + "', '" + TextBox1.Text + "', '" + TextBox2.Text + "', '" + TextBox6.Text + "'"+
"'" + TextBox7.Text + "', '" + TextBox8.Text + "', '" + TextBox9.Text + "' )";
conn.Open();
InsertCommand.ExecuteNonQuery();
string selectText = "select * from phone order by id desc");
SqlDataReader Sdr = new SqlDataReader(selectText, cn);
GridView1.DataSource = Sdr;
GridView1.DataBind();
conn.Close();
}

