Use SQL to create a table with automatic growth fields in Access

xiaoxiao2021-03-06  67

Author: zfive5 (zhaozidong) Email: zfive5@yahoo.com The SQL statement creates a table with an automated growth field in the Access database (today's colleague asked me this question), I received all Access through Google The retention word, see AutoInCrement inspiration, about Access reserved word collection in "My Favorites - Hanjiang Snow", everyone can take a look! SQL statement: Create Table AA (AA1 AutoIncrement, AA2 VARCHAR (100) VC code: // # import "c: // program files // common files // system // ado // msado15.dll" no_namespace rename ("eof", "adoeof" void ctestdlg :: OnbnclicKedok () { // Todo: Add control notification handler code :: COINTIALIZE (NULL); {cstring strconnection = ""; cstring strmsg = ""; strconnection.format (_t ("provike = microsoft.jet.Oledb.4.0; data Source =% s; persist security info = false; ") /," c: //db1.mdb "); _ConnectionPtr Hadoconnect; HRESULT HR = Hadoconnect.createInstance (__UUIDOF (Connection)); IF (Failed (HR)) { :: Messagebox (Null, _T ("The database driver in your system is problematic."), _T ("prompt"), MB_ok | MB_ICONITION;}

_RecordsetPtr rs; CString strSql; try {hAdoConnect-> ConnectionTimeout = 18; hAdoConnect-> ConnectionString = _bstr_t (strConnection); hAdoConnect-> Open (_bstr_t (L ""), _bstr_t (L ""), _bstr_t (L "") , -1); Hadoconnect-> Execute (_BSTR_T ("Create Table AA (AA1 AutoIncrement, AA2 VARCHAR (100))"), NULL, ADCMDTEXT);} catch (_COM_ERROR & E) {_BSTR_T BSTROR = E.DESCRIPTION (); Strmsg = (lpctstr) bstrerror; :: MessageBox (NULL, STRMSG, _T ("Tips"), MB_OK | MB_ICONINFORMATION; Return;}} counitialize ();}

转载请注明原文地址:https://www.9cbs.com/read-85517.html

New Post(0)