【发布时间】:2021-05-22 11:08:19
【问题描述】:
private void button5_Click(object sender, EventArgs e)
{
textBox4.Text = textBox3.Text;
SqlConnection con = new SqlConnection(sqlstring);
con.Open();
string sql = "SELECT productid, name, ListPrice as Price FROM Production.Product where
ProductID = @productid";
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
cmd.Parameters.Add("@productid", SqlDbType.Int).Value = int.Parse(textBox4.Text);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView2.DataSource = dt;
cmd.Dispose();
con.Close();
}
我想添加新行而不是删除以前的行然后添加新的 sqlstring 是在开始时初始化的 const 我不知道最后 4 行是做什么的,但他们在我看到的教程中使用了它们
【问题讨论】:
标签: c# .net datagridview