1protected void Button1_Click(object sender, EventArgs e)
2 {
3 SqlConnection sqlconn1 = new SqlConnection("server=.;database=start;uid=sa;pwd=");
4 string insertlink = "insert into link(weblink,webname)values(@link,@name)";//link name是两个textbox控件
5 SqlCommand insertlinkcmd = new SqlCommand(insertlink,sqlconn1); //定义sqlcommand
6 insertlinkcmd.Parameters.AddWithValue("@link", link.Text); //添加参数变量
7 insertlinkcmd.Parameters.AddWithValue("@name", name.Text);
8 sqlconn1.Open();
9 int result = insertlinkcmd.ExecuteNonQuery(); //执行SQL语句command
10 sqlconn1.Close();
11 }
12
13
2 {
3 SqlConnection sqlconn1 = new SqlConnection("server=.;database=start;uid=sa;pwd=");
4 string insertlink = "insert into link(weblink,webname)values(@link,@name)";//link name是两个textbox控件
5 SqlCommand insertlinkcmd = new SqlCommand(insertlink,sqlconn1); //定义sqlcommand
6 insertlinkcmd.Parameters.AddWithValue("@link", link.Text); //添加参数变量
7 insertlinkcmd.Parameters.AddWithValue("@name", name.Text);
8 sqlconn1.Open();
9 int result = insertlinkcmd.ExecuteNonQuery(); //执行SQL语句command
10 sqlconn1.Close();
11 }
12
13