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
John
NA
43
34.1k
How to update listbox after inserting new row
Dec 12 2010 12:41 PM
HI all
Im trying to get my from to insert new information into a database and display it. right now the information inputted goes into the database file. but the lstbox i have on my form displaying the current records doesnt get updated.
here is the coding for the button:
string dbconnection = "Provider=Microsoft.Jet.OLEDB.4.0;" + @"data source=Book.mdb";
OleDbConnection con = new OleDbConnection(dbconnection);
OleDbCommand cmd = new OleDbCommand("INSERT INTO Books(BookKey,Title,Pages,AuthorKey,PublisherID) VALUES (?,?,?,?,?)", con);
cmd.Parameters.Add("@BookKey", OleDbType.VarChar, 50, "BookKey").Value = textBox1.Text;
cmd.Parameters.Add("@Title", OleDbType.VarChar).Value = textBox2.Text;
cmd.Parameters.Add("@Pages", OleDbType.VarChar).Value = textBox3.Text;
cmd.Parameters.Add("@AuthorKey", OleDbType.VarChar).Value = textBox4.Text;
cmd.Parameters.Add("@PubliherID", OleDbType.VarChar).Value = textBox5.Text;
con.Open();
cmd.Connection = con;
cmd.ExecuteNonQuery();
con.Close();
refreshlist();
Hope someone can help
Regards
Reply
Answers (
15
)
using a Variable to set control properties
Creating an object from type / casting into correct type from list of baseclasses