Describe how to use an Access database
DataTable tb;oledbdataadapter da;Private voidBinddata () {stringDatestr =DateTime.Now.ToShortDateString (); TB= db. QueryTable ("SELECT [Account]. [id], [pid],[account]. [Username],[account]. [Password],[account]. [Otherdata],iif (IsNull (Success), '-', ' success ') ' as ' from the account ' left join [record] on ([aid]=[account].[ ID] and [record]. [getdate]= '"+ Datestr +"') where ([pid]="+ idindex.tostring () +")"); OleDbConnection con=NewOleDbConnection (db.connectionstring); Da=NewOleDbDataAdapter ("SELECT * from Account", con); OleDbCommandBuilder SCB=NewOleDbCommandBuilder (DA);//can automatically generate updates, INSERT, delete SQL statementsScb. QuotePrefix ="["; Scb. QuoteSuffix="]"; Datagridview1.datasource=TB;}
Mainly through the implementation of OleDbCommandBuilder, it is important to note that there is no need to manually set the OleDbCommandBuilder to delete, change the statement, but if the query is complex is not correctly generated delete, change the statement, So to manually set the simplest query statement, it is simple, a few lines of code to take care of everything.
DataGridView Implementing Automatic Updates to the database