1.access2007
Using System.Data.OleDb;
Using System.IO;
Using System.Diagnostics;
stringdatafile = Path.getdirectoryname (Process.getcurrentprocess (). Mainmodule.filename) +"\\CustomaryOrder.accdb"; Private voidBtnlogin_click (Objectsender, EventArgs e) { //string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + AppDomain.CurrentDomain.BaseDirectory + " CUSTOMARYORDER.ACCDB; Persist Security info=true "; //connecting to a databaseOleDbConnection con =NewOleDbConnection (); //AccessCon. ConnectionString ="provider=microsoft.ace.oledb.12.0; Jet oledb:database password=123456;data source="+datafile+""; Con. Open (); OleDbCommand cmd=NewOleDbCommand (); Cmd. Connection=con; Cmd.commandtext="SELECT * from Login";//1 is the name of the tableOleDbDataReader reader =cmd. ExecuteReader (); while(reader. Read ()) {stringStr=reader. GetValue (1). ToString (); } reader. Close (); Con. Close (); Panellogin.hide (); Frmcustomaryorder myfrm=NewFrmcustomaryorder (); Myfrm.mdiparent= This; Myfrm.windowstate=formwindowstate.maximized; Myfrm.show (); }
Database Connection Memo