First of all you need to add a reference to Microsoft.Office.Interop.Access under the .Net tab in the 'Add Reference' dialog box in Visual Studio.
Then create two variables, one for your textbox1 text, another for your textbox2 text like so:
var foo = textbox1.Text;
var bar = textbox2.Text;
Then add using Microsoft.Office.Interop.Access; to your using statements.
Then you need to make a new instance of the Application class so add the following to your method:
var ap = new Microsoft.Office.Interop.Access.Application();
Then open your database like so:
ap.OpenCurrentDatabase(@"C:\Users\qianren\Desktop\iplan version\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\log.accdb");
Then run an insert query like so:
ap.DoCmd.RunSQL(String.Format("INSERT INTO login ( Username, [Password] ) SELECT "{0}" AS LG, "{1}" AS PW;", foo, bar));
If you are unsure of the syntax, you can design this query using the Microsoft Access query designer, click on the SQL button on the bottom right hand side of the screen and copy the SQL over.
Then close your database like so:
ap.CloseCurrentDatabase();
Finally, clean up your unmanaged object like this:
Marshal.ReleaseComObject(ap); //Sorry this is nearly a year late, just noticed it!