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
Zeb Muhammad
NA
67
18.2k
DataGridView Date save
Jul 29 2017 8:00 AM
Dear Friends,
I want to save Date from DataGridView to Database.
my Date Datatype is DateTime in DB.
please, check my code
private void button4_Click(object sender, EventArgs e)
{
con.Open();
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
SqlCommand cmd = new SqlCommand("INSERT INTO cat1_tab (myDate) VALUES(@myDate)", con);
cmd.Parameters.Add("@mydate",dataGridView1.Rows[i].Cells[7].Value.ToString("yyyy-MM-dd"));
cmd.ExecuteNonQuery();
MessageBox.Show("save");
con.Close();
}
}
Thx
Reply
Answers (
2
)
autogenerate barcode
Database search