Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Answers
DataGridView Date save
Zeb Muhammad
7y
207
1
Reply
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
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
autogenerate barcode
Database search