ich möchte für ACCESS 2007 eine mdb erstellen lassen, das erstellen der Tabelle, Abfrage funktioniert super nur sobalt ich die Abfragen mit ORDER BY Index oder name erweitere, wird die Sicht in der mdb NICHT erstellt und es kommt keine Fehlermeldung.
Im Beispiel die Sichr Info2, Info3 wird nicht erstellt.
kennt einer das Problem oder hat da einer eine Idee?
Code: Alles auswählen
EnableExplicit
XIncludeFile "ADOmate.pbi"
Procedure.s fnCnn()
Protected conStr.s
conStr = "Provider=Microsoft.Jet.OLEDB.4.0;"
conStr = conStr + "Data Source="
conStr = conStr + "Info.mdb;"
ProcedureReturn conStr
EndProcedure
;
; erstellte nur die DB
;
Procedure DB_Erstellen()
Protected DBid.i
DBid = ADOmate_CreateDatabase(fnCnn())
If DBid
ADOmate_CloseDatabase(DBid)
Else
MessageRequester("ADO Fehler!", ADOmate_GetLastErrorDescription())
EndIf
EndProcedure
;
; Erstellt eine Tabelle mit Feld Id Autowert mit Primärschlüssel
; Datum/Zeit als Zeitstempel
;
Procedure TabelleErstellen(conString.s)
Protected myCon, cmd.s
myCon = ADOmate_OpenDatabase(conString)
If myCon
cmd = "CREATE TABLE tabInfo (" +
"id COUNTER NOT NULL PRIMARY KEY, " +
"VgNr Text(9), " +
"Bemerkung Text(255), " +
"Memo1 MEMO, " +
"Datum TIMESTAMP NULL DEFAULT NOW()" +
");"
ADOmate_DatabaseUpdate(myCon, cmd)
ADOmate_CloseDatabase(myCon)
Else
MessageRequester("ADO Fehler!", ADOmate_GetLastErrorDescription())
EndIf
EndProcedure
;
; Sicht Info erstellen
;
Procedure AbfrageInfoErstellen(conString.s)
Protected myCon, cmd.s
myCon = ADOmate_OpenDatabase(conString)
If myCon
;ORDER BY tabInfo.Datum DESC
cmd = "CREATE VIEW info1 AS SELECT tabInfo.VgNr, tabInfo.Bemerkung, tabInfo.Datum FROM tabInfo;"
ADOmate_DatabaseUpdate(myCon, cmd)
cmd = "CREATE VIEW info2 AS SELECT tabInfo.VgNr, tabInfo.Bemerkung, tabInfo.Datum FROM tabInfo ORDER BY 3 DESC;"
ADOmate_DatabaseUpdate(myCon, cmd)
cmd = "CREATE VIEW info3 AS SELECT tabInfo.VgNr, tabInfo.Bemerkung, tabInfo.Datum FROM tabInfo ORDER BY tabInfo.Datum DESC;"
ADOmate_DatabaseUpdate(myCon, cmd)
cmd = "CREATE VIEW info4 AS SELECT tabInfo.VgNr, tabInfo.Bemerkung, tabInfo.Datum FROM tabInfo;"
ADOmate_DatabaseUpdate(myCon, cmd)
ADOmate_CloseDatabase(myCon)
Else
MessageRequester("ADO Fehler!", ADOmate_GetLastErrorDescription())
EndIf
EndProcedure
;
;
;
Procedure NeueDB_erstellen()
Protected DbDatei.s, cnnStr.s
DbDatei = "Info.mdb"
; falls die Datei schon vorhanden ist löschen
If FileSize(DbDatei) > 0
DeleteFile(DbDatei)
EndIf
cnnStr = fnCnn()
; Falls die DB nicht vorhanden ist erst die DB erstellen
If FileSize(DbDatei) = -1
DB_Erstellen()
EndIf
;Tabelle Info erstellen
TabelleErstellen(cnnStr)
;Sicht erstellen
AbfrageInfoErstellen(cnnStr)
EndProcedure
NeueDB_erstellen()