TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dana Maria
NA
16
10.8k
Insert not taking effects in Database
Apr 28 2013 9:42 AM
Hello everyone!
I have a slightly problem. I want to insert a row in database during the running program. After clicking the button I have no error but when that form close I can"t see row inserted, it"s not in database. But i want to visualise from the same form where i insert i can see row. After closing it, the row disappear. Please help! Why is not commiting in database, why it is not inserting in database too?
Here is my code:
try
{
detaliiviz_form.connect.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO Detinute([cod_caracteristici],[marca],[perioada],[tara]) VALUES(@cod_caracteristici,@marca,@perioada,@tara)",detaliiviz_form.connect);
cmd.Parameters.AddWithValue("@cod_caracteristici","ete");
cmd.Parameters.AddWithValue("@marca", modifprof_form.listview.SelectedItems[0].SubItems[3].Text.Trim());
cmd.Parameters.AddWithValue("@perioada", dP_per1.Value.ToString("dd/mm/yyyy", CultureInfo.InvariantCulture) + "-" + dP_per2.Value.ToString("dd/mm/yyyy", CultureInfo.InvariantCulture));
cmd.Parameters.AddWithValue("@tara", tb_taraprof.Text.Trim());
cmd.ExecuteNonQuery();
detaliiviz_form.connect.Close();
}
catch(SqlException ex)
{
MessageBox.Show(ex.ToString());
}
this.Close();
Reply
Answers (
7
)
Auto Backup In SQL Server 2008R2
Database