set collate to 'machine' create database 'e:\mydbc.dbc' create table 'e:\tablea.dbf' name 'tablea' ( ; author_id i null default autoinckey(left(justfname(dbf()),(len(justfname(dbf()))-4)),"author_id"), ; username c(20) null, ; user_code c(70) null, ; password c(20) null default "123456", ; author_email c(50) null default "unk", ; show_email l null default .f., ; homepage c(50) null default "http://@@@@@.@@@", ; location c(50) null default "[unk]", ; signature m null default "[unk]", ; no_of_posts i null default 0, ; join_date t null default datetime(), ; active l null default .t., ; status i null default 0, ; avatar c(100) null default "" ; ) index on user_code tag user_code index on username tag username alter table 'tblauthor' add primary key author_id tag author_id create table 'e:\dbkeys.dbf' name 'dbkeys' ( ; ctable c(16) null, ; ccolumn c(16) null, ; inextid i null ; ) index on inextid tag inextid index on upper(ctable) tag ctable index on upper(ccolumn) tag ccolumnCode that is inside the Stored Procedure block in the DBC:
Function AutoIncKey LParameters pcTable,pcColumn pcTable = Upper(pcTable) pcColumn = Upper(pcColumn) local lnArea, liRetVal lnArea = select() If !used("dbkeys") Use ( "dbkeys" ) In 0 Shared Select dbkeys lNothing = CursorSetProp("Buffering",1) Set Order To Else Select dbkeys EndIf Do While !FLock() EndDo Locate For Upper(cTable) = pcTable and Upper(cColumn) = pcColumn If Found() Replace iNextID With iNextID + 1 Flush Unlock Else Insert Into dbkeys (cTable,cColumn,iNextID) Values (pcTable,pcColumn,1) Flush Unlock EndIf Select (lnArea) liRetVal = dbkeys.iNextId Return liRetVal EndFunc Function Now Set Date to American Set Mark to "/" tOutDT = Datetime() Set Date to ANSI Set Mark to "." Return tOutDT EndFuncThe VBScript code that breaks:
strCon = "Provider=VFPOLEDB.1;Data Source=E:\mydbc.DBC;Password="""";Collating Sequence=MACHINE" Set AdoCon = CreateObject("ADODB.Connection.2.7") With AdoCon .ConnectionString = strCon .CursorLocation = 2 .Mode = 16 .Open End With AdoCon.Execute("Insert Into tablea (UserName) Values ('steve')")