hello!
i am just trying to read an excel-sheet (name: "kv.xls", first table = "Tabelle1" ) (MS office 2000), but it does not work.
i can open the 'database', but my select-query is not accepted.
is there anyone who has an idea?
thanks a lot!
kimio
----------------------------------------------------
pw.s:pw=""
user.s:user=""
db_name.s:db_name="kv"
odbc.s:odbc="kv" ;ODBC-driver
conn.b:conn=4
;Gosub init_db
Gosub open_db
query.s = "Select * FROM Tabelle1"
Gosub db_query
While NextDatabaseRow() <> 0 ; gefundene einträge abarbeiten
sa$=GetDatabaseString(0) ;reihe 0 = pho NN
;sb$=GetDatabaseString(1) ;reihe 1 = pho VN+NN
;sc$=GetDatabaseString(2) ;reihe 2 = pho Fa.
Debug sa$
;Debug sb$
;Debug sc$
Wend
;CloseDatabase(3)
CloseDatabase(4)
End
; >>>>>>>> subroutinen
db_query: ;führt in geöffneter db-verbindung die db-query query.s aus
If DatabaseQuery(query.s) = 0
MessageRequester("db_query:", "fehlgeschlagen",#PB_MessageRequester_Ok)
End
EndIf
Return
open_db: ;subroutine - öffnet datenbankverbindung
; pw.s -> password
; user.s -> user
; db_name.s -> db.name
; odbc.s -> odbc-name
; conn.b -> nummer der db-verbindung
Gosub init_db ;initialisieren (auswählen der db)
If OpenDatabase(conn, db_name, user,pw) = 0
MessageRequester("OpenDB fehlgeschlagen", "Fehler",#PB_MessageRequester_Ok)
EndIf
Return
init_db:
InitDatabase()
If ExamineDatabaseDrivers()
While NextDatabaseDriver()
If DatabaseDriverName() = odbc
Base_OK.b = 1
EndIf
Wend
EndIf
If Base_OK = 0
MessageRequester("ODBC-driver:", "not found",#PB_MessageRequester_Ok)
EndIf
Return
Read MS-Excel from PB - my mySql-queries dont work
ODBC: do i use normal SQL-syntax to communicate excelsheet?
thanks a lot!
ok, the SELECT statement has to be written in upper cases....
and the statement doesnt need a $ behind 'tabelle1'. this is because the whole query is a string, so you dont have to use a '$' behind the table-name (i have also tried it with $ behind tabelle1).
my query still does not work.
my question is now:
if you use the ODBC-interface for communication with an excel-sheet do i use common SQL-syntax? i have not found any hint for this, only for opening a connection to the excel-sheet via ODBC
thanks in advance!
kimio
ok, the SELECT statement has to be written in upper cases....
and the statement doesnt need a $ behind 'tabelle1'. this is because the whole query is a string, so you dont have to use a '$' behind the table-name (i have also tried it with $ behind tabelle1).
my query still does not work.
my question is now:
if you use the ODBC-interface for communication with an excel-sheet do i use common SQL-syntax? i have not found any hint for this, only for opening a connection to the excel-sheet via ODBC
thanks in advance!
kimio
How to read Excel....
ok....
my ODBC looks like:
DSN (data source name): kv (excel-table='kv.xls'; sheet='Tabelle1', i use excel 2000)
version: excel 97-2000
path to excel-folder: ok
write protected
look at my example on top: the database-connection is opened correctly (sub open_db:), i get no error-message.
can you perhaops show me a working pb-code (opendatabase and sql-query)?
thanks a lot!
kimio
my ODBC looks like:
DSN (data source name): kv (excel-table='kv.xls'; sheet='Tabelle1', i use excel 2000)
version: excel 97-2000
path to excel-folder: ok
write protected
look at my example on top: the database-connection is opened correctly (sub open_db:), i get no error-message.
can you perhaops show me a working pb-code (opendatabase and sql-query)?
thanks a lot!
kimio