public void dobPred(dobPredm dobPredm) //добавление препода { cnn.Open(); comand = cnn.CreateCommand(); comand.CommandText = "INSERT INTO Predmet (Name_Predmeta, Price) VALUES (@Name_Predmeta,@Price)"; comand.Parameters.AddWithValue("@Name_Predmeta", Convert.ToString(dobPredm.dobNamePred.Text)); comand.Parameters.AddWithValue("@Price", Convert.ToString(dobPredm.dobPricePred.Text)); comand.ExecuteNonQuery(); cnn.Close(); }
public void rezerv1(dobPredm dobPredm) // выгрузка таблица Предмет { cnn.Open(); zapros = (" SELECT Name_Predmeta AS [Предмет], Price AS [Цена] FROM Courses.dbo.Predmet"); SqlDataAdapter da = new SqlDataAdapter(zapros, cnn); SqlCommandBuilder cb = new SqlCommandBuilder(da); DataSet ds = new DataSet(); da.Fill(ds, "Predmet"); dobPredm.DataPredmet.DataSource = ds.Tables[0]; cnn.Close(); }