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
Scale black
NA
7
0
Update database
Apr 20 2007 9:44 AM
Im trying to update the content in the database but it doesnt work i dont understand why. I commented most of the code tell me if something is unclear Get content code: //if creating new file use textbox1 rather then the double clicked data cell string fns = ""; if (open == false) { dataGridView1.CurrentCell = this.dataGridView1[0, e.RowIndex]; fns = dataGridView1.CurrentCell.Value.ToString(); } else { //use filename box (file creation) fns = textBox1.Text; } // get content where name == fns SqlConnection sql = new SqlConnection(sqlcon); a = new SqlDataAdapter("SELECT [Content], [primkey], [Name] FROM Keeper WHERE [Name] ='" + fns + "'", sqlcon); try { a.Fill(s, "Keeper"); foreach (DataRow dr in s.Tables[0].Rows) { dataGridView2.DataSource = s; dataGridView2.DataMember = "Keeper"; } //get content from datagrid insert into richtextbox dataGridView2.CurrentCell = this.dataGridView2[0, 0]; richTextBox1.Text = dataGridView2.CurrentCell.Value.ToString(); } catch (SqlException sqlexcp) { MessageBox.Show(sqlexcp.Message.ToString()); } //close connection, reset bool, bring up editor sql.Close(); open = false; richTextBox1.BringToFront(); Save content: //get content from textbox insert into datagrid dataGridView2.CurrentCell = this.dataGridView2[0, 0]; dataGridView2.CurrentCell.Value = richTextBox1.Text; //update DB SqlCommandBuilder mySqlCommandBuilder = new SqlCommandBuilder(a); a.Update(s, "Keeper");
Reply
Answers (
1
)
can you give me manual coding for editing , updating , deleting and selecting a row in gridview using storedprocedures,It must not use SqlDataSourceControl
How to implement Data Access Layer