SQLiteConnection con = new SQLiteConnection(); con.ConnectionString = conStr; try { con.Open(); if (con.State == ConnectionState.Open) { MessageBox.Show("Открыто "+DateTime.Now.ToString()); } SQLiteCommand command = new SQLiteCommand(); command.Connection = con; command.CommandText = "Insert into Tovar(Name,Cost,Kol,Date) values('"+tbName.Text+"',"+ Convert.ToInt32(tbCost.Text) + "," + Convert.ToInt32(tbKol.Text) +"," + DateTime.Now + ");";// вот тут вылетает. command.ExecuteNonQuery(); ds.Reset(); dataAdapter.Fill(ds,"Товары"); dataGrid1.DataSource = ds.Tables["Товары"].DefaultView;
command.CommandText = "Insert into [Tovar]([Name],[Cost],[Kol],[Date]) values(@Name,@Cost,@Kol,@Date)"; command.Parameters.AddWithValue("@Name",tbName.Text); command.Parameters.AddWithValue("Cost",tbCost.Text); command.Parameters.AddWithValue("@Kol",tbKol.Text); command.Parameters.AddWithValue("Date", DateTime.Now);