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
narasiman rao
NA
519
768.3k
save the data grid view data in to data base.
Jan 12 2013 12:14 AM
Database as follows;
Date datetime
Session int
Course varchar(20)
Faculty_ Code varchar(20)
but i want save the data grid view data in to the data base.
private void BtnSave_Click(object sender, EventArgs e)
{
Save Details();
}
private void SaveDetails()
{
try
{
DataTable dt = new DataTable();
dt.Columns.Add("date", typeof(string));
dt.Columns.Add("sess", typeof(int));
dt.Columns.Add("crs", typeof(string));
dt.Columns.Add("Fac", typeof(string));
for (int i = 0; i < datagridView.RowCount; i++)
{
for (int j = 2; j < datagridView.ColumnCount; j++)
{
if (datagridView[j, i].Value != null)
{
dt.Rows.Add(datagridView[0, i].Value.ToString(), datagridView[1, i].Value.ToString(), datagridView[j, i].Value.ToString(), datagridView.Columns[j].HeaderText.ToString());
}
}
}
dataGridView1.DataSource = dt;
}
catch (Exception Ex1)
{
MessageBox.Show(Ex1.ToString(), "Error", MessageBoxButtons.OK);
}
}
i save the data grid view data into the another data grid view data using data table.
i want to save the data grid view data in to the data base.
how to do.please help me.
Reply
Answers (
3
)
one Store procedure for insert and update
hwo to validate null values in data grid view using csharp