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...

Recommended Answers

All 8 Replies

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();

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?

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.

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.

Form2 has data entry UI?
Sorry ( noob ), does every form have this or do you have to add it?

Form2 has data entry UI?
Sorry ( noob ), does every form have this or do you have to add it?

one to add the database.

one to add the database.

Yeah, i've done that.
I open a second form and mainform is still displayed in background, do i have to close and reopen the mainform?

Please post your code here.

Here's my whole project, you probably can't build it because it involves handshaking with PIC16F877..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.