Dobry den,
potreboval bych poradit mam db a pres adapter do ni vkladam data delal jsem to podle clanku na zive.cz myslim si ze to mam uplne stejny a ten novy radek se mi do db nezapise a zaroven to ani nenapise zadnou chybu tak nevim kde je problem?
connection.Open();
dataSet = new DataSet();
adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand("SELECT * FROM Klienti", connection);
adapter.InsertCommand = new SqlCommand("INSERT INTO Klienti(Jmeno, Prijmeni, RodneCislo, AdresaBydliste, Telefon, Heslo) VALUES(@Jmeno, @Prijmeni, @RodneCislo, @AdresaBydliste, @Telefon, @Heslo)", connection);
adapter.DeleteCommand = new SqlCommand("DELETE FROM Klienti WHERE Id=@Id", connection);
adapter.InsertCommand.Parameters.Add("@Jmeno", SqlDbType.VarChar, 50, "Jmeno");
adapter.InsertCommand.Parameters.Add("@Prijmeni", SqlDbType.VarChar, 50, "Prijmeni");
adapter.InsertCommand.Parameters.Add("@RodneCislo", SqlDbType.VarChar, 50, "RodneCislo");
adapter.InsertCommand.Parameters.Add("@AdresaBydliste", SqlDbType.VarChar, 50, "AdresaBydliste");
adapter.InsertCommand.Parameters.Add("@Telefon", SqlDbType.VarChar, 50, "Telefon");
adapter.InsertCommand.Parameters.Add("@Heslo", SqlDbType.VarChar, 50, "Heslo");
adapter.DeleteCommand.Parameters.Add("@Id", SqlDbType.Int, 4, "Id");
adapter.Fill(dataSet, "Klienti");
//Pridani klienta
DataRow novyKlient = dataSet.Tables["Klienti"].NewRow();
novyKlient["Jmeno"] = "asasdewd";
novyKlient["Prijmeni"] = "asasdewd";
novyKlient["RodneCislo"] = "asasdewd";
novyKlient["AdresaBydliste"] = "asasdewd";
novyKlient["Telefon"] = "asasdewd";
novyKlient["Heslo"] = "asasdewd";
dataSet.Tables["Klienti"].Rows.Add(novyKlient);
//Ulozeni do databaze
adapter.Update(dataSet, "Klienti");
//vymazani vsech zaznamu
dataSet.Clear();
//opetovne naplneni
adapter.Fill(dataSet, "Klienti");
Dekuji za pomoc