I'm using an access database to save plain textboxes.
I've made a connection with the database. Now i need to find the code to add the textboxes to my database.
I've tried to add with the bindingnavigator but it won't work...
please help...
Use System.Data.OleDb connection, command, and parameter classes.
OleDbConnection cn=new OleDbConnection(@"put_connection_string_here");
OleDbCommand cmd=new OleDbCommand("insert into tableName (col1,col2) values (@para1,@para2)",cn);
cmd.Parameters.AddWithValue("@para1",TextBox1.Text);
cmd.Parameters.AddWithValue("@para2",TextBox2.Text);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
I've found the way using the bindingnavigator, but there's one problem, i use 2 forms, one to add the database and one to display items. So i need to restart my program everytime I added something before i can see it in my main form. How can i refresh my database of my mainform?
Presume that the Form2 has data entry UI.
In the click handler of button,
Form2 frm=new Form2();
frm.ShowDialog();
//Write here code to fetch & rebind the datasource.
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
Form2 has data entry UI?
Sorry ( noob ), does every form have this or do you have to add it?
one to add the database.
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
Please post your code here.
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241