Update code:
SqlCommand cmd = new SqlCommand("ShowByName", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Product_name", SqlDbType.NVarChar, 35);
cmd.Parameters["@Product_name"].Value = "Сыр";
dAdapt.UpdateCommand = cmd;
dAdapt.Update(Table_1, "MyProducts");
// dataGridView1.DataSource = Table_1.Tables["MyProducts"];
All code:
SqlConnection cn = new SqlConnection("Data Source=microsof-1346c9;" +
"Integrated Security=SSPI; Initial Catalog=Товары");
DataSet Table_1; SqlDataAdapter dAdapt;
public Form1()
{
InitializeComponent();
Table_1 = new DataSet("Products");
dAdapt = new SqlDataAdapter("ShowMyProducts", cn);
dAdapt.Fill(Table_1, "MyProducts");
// DataTable MyTab = new DataTable();
dataGridView1.DataSource=Table_1.Tables["MyProducts"];
}
private void button1_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("ShowByName", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Product_name", SqlDbType.NVarChar, 35);
cmd.Parameters["@Product_name"].Value = "Сыр";
dAdapt.UpdateCommand = cmd;
dAdapt.Update(Table_1, "MyProducts");
// dataGridView1.DataSource = Table_1.Tables["MyProducts"];
}


Sign In
Create Account


Back to top









