home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Tool Box
/
SIMS_2.iso
/
bp_1_94
/
vbwin
/
prof_db
/
bspsel.bas
Wrap
BASIC Source File
|
1994-04-08
|
6KB
|
215 lines
' DEKLARATIONSTEIL
'********************************************************************
' BeginnW3ISQL_Declared
'********************************************************************
Global Const ITEMSIZE = 255
Global Const TABUNITS = 5
Type COLTYPE
Name As String
Type As Integer
Len As Integer
Buffer As String
End Type
'Konstanten
Global Const SUCCEED = 1
Global Const fail = 0
Global Const NO_MORE_RESULTS = -2
Global Const SQLCHAR = 0
Global Const SQLSMINT = 1
Global Const SQLINT = 2
Global Const SQLFLOAT = 3
Global Const SQLSMFLOAT = 4
Global Const SQLDECIMAL = 5
Global Const SQLSERIAL = 6
Global Const SQLDATE = 7
Global Const SQLMONEY = 8
Global Const SQLNULL = 9
Global Const SQLDTIME = 10
Global Const SQLBYTES = 11
Global Const SQLTEXT = 12
Global Const SQLVCHAR = 13
Global Const SQLINTERVAL = 14
Global dbproc As Long
Global backend_present As Integer
'Limits
Global Const MAXCOLS = 40
'Datenbankfunktionen
Declare Function dbbind Lib "w3isql.dll" (ByVal dbproc%, ByVal ColNum%, ByVal DestType%, ByVal DestLen&, ByVal Dest$) As Integer
Declare Function dbcmd Lib "w3isql.dll" (ByVal dbproc%, ByVal cmd$) As Integer
Declare Sub dbclose Lib "w3isql.dll" (ByVal dbproc%)
Declare Function dbcollen Lib "w3isql.dll" (ByVal dbproc%, ByVal ColNum%) As Integer
Declare Function dbcolname Lib "w3isql.dll" (ByVal dbproc%, ByVal ColNum%) As Long
Declare Function dbcoltype Lib "w3isql.dll" (ByVal dbproc%, ByVal ColNum%) As Integer
Declare Function dbxldata Lib "w3isql.dll" (ByVal dbproc%, ByVal ColNum%) As String
Declare Function dbdata Lib "w3isql.dll" (ByVal dbproc%, ByVal ColNum%) As Long
Declare Function dbdatlen Lib "w3isql.dll" (ByVal dbproc%, ByVal ColNum%) As Integer
Declare Function dbcount Lib "w3isql.dll" (ByVal dbproc%) As Integer
Declare Sub dbexit Lib "w3isql.dll" ()
Declare Function dbinit Lib "w3isql.dll" () As Integer
Declare Function dbinst Lib "w3isql.dll" () As Integer
Declare Function dbnextrow Lib "w3isql.dll" (ByVal dbproc%) As Integer
Declare Function dbnumcols Lib "w3isql.dll" (ByVal dbproc%) As Integer
Declare Function dbconnect Lib "w3isql.dll" (ByVal user$, ByVal password$) As Integer
Declare Function dbopen Lib "w3isql.dll" (ByVal login&, ByVal s$) As Integer
Declare Function dbresults Lib "w3isql.dll" (ByVal dbproc%) As Integer
Declare Function dbrows Lib "w3isql.dll" (ByVal dbproc%) As Integer
Declare Function dbsqlexec Lib "w3isql.dll" (ByVal dbproc%) As Integer
Declare Function dbuse Lib "w3isql.dll" (ByVal dbproc%, ByVal dbname$) As Integer
Declare Sub dbwinexit Lib "w3isql.dll" ()
'VisualBasicSupport
Declare Function vbstring Lib "w3isql.dll" (ByVal pointer&) As String
Declare Function vbstrbas Lib "w3isql.dll" Alias "vbstring" (ByVal vbstr$) As String
Declare Function vbdeftab Lib "w3isql.dll" (EdCtl As Control) As Integer
Declare Function vbmemtab Lib "w3isql.dll" (ByVal pos%) As Integer
Declare Function vbsettab Lib "w3isql.dll" (EdCtl As Control) As Integer
Declare Sub VBGetDouble Lib "w3isql.dll" (Dest#, ByVal Source&)
Declare Sub VBGetLong Lib "w3isql.dll" (Dest&, ByVal Source&)
Declare Sub VBGetInt Lib "w3isql.dll" (Dest%, ByVal Source&)
'LowLevel
Declare Function strtrimr Lib "w3isql.dll" (lpStr As Long) As Long
'********************************************************************
' EndeW3ISQL_Declared
'********************************************************************
Function SQL_SELECT()
Dim anz_row As Integer
Dim anz_col As Integer
Dim i As Integer
Dim ret_code As Integer
Dim n_row As Long
Dim tmp As String
Dim strlen As Integer
Dim Col() As coltype
On Error GoTo err_sql_select_request
'
' Datenbank ÷ffnen
'
If dbcmd(dbproc, "DATABASE beispiel") = fail Then
sql_select_request = False
Exit Function
End If
If dbsqlexec(dbproc) = fail Then
sql_select_request = False
Exit Function
End If
'
' Selectstatement in den Commandbuffer schreiben
'
If dbcmd(dbproc, "SELECT * FROM kunden") = fail Then
sql_select_request = False
Exit Function
End If
' SQL-Statement im Backend ausfⁿhren
If dbsqlexec(dbproc) = fail Then
sql_select_request = False
Exit Function
End If
' Ergebniss in den Datenbuffer schreiben
If dbresults(dbproc) = fail Then
sql_select_request = False
Exit Function
End If
'Anzahl der Datensaetze in der Ergebnismenge ermitteln
anz_row = dbcount(dbproc)
'Anzahl der Spalten feststellen
anz_col = dbnumcols(dbproc)
'
' Arrays vergroessern
'
ReDim Col(0 To anz_col) As coltype
ReDim result_array(0 To anz_col) As String
grid1.FixedRows = 1
grid1.FixedCols = 1
grid1.Cols = anz_col + 1
'
'Spalten auslesen
'
For i = 1 To anz_col
Col(i).name = RTrim(vbstring(dbcolname(dbproc, i)))
Col(i).Len = Len(Col(i).name)
Col(i).buffer = String$(ITEMSIZE, 0)
ret_code = dbbind(dbproc, i, SQLCHAR, ITEMSIZE - 20, Col(i).buffer)
If ret_code = fail Then
sql_select_request = False
Exit Function
End If
'Spaltennamen im Ergebnissgrid anzeigen
grid1.Col = i
grid1.Text = Col(i).name
Next i
n_row = 0
'
'Datenfelder auslesen
'
While dbnextrow(dbproc) <> NO_MORE_RESULTS
'
' ZΣhler der gelesenen DatensΣtze erh÷hen
' damit das Ergebnisgrid vergr÷▀ert werden kann
'
n_row = n_row + 1
grid1.Rows = n_row + 1
'
' Zeilen nummerieren
'
grid1.Row = n_row
grid1.Col = 0
grid1.Text = n_row
For i = 1 To anz_col
tmp$ = vbstrbas(Col(i).buffer)
strlen = Len(tmp$)
'
' Feststellen ob gelesener Datensatz lΣnger als
' der bislang lΣngste String
'
If strlen > Col(i).Len Then
Col(i).Len = strlen
End If
'
' String in die Zelle des Ergebnissgrids schreiben
'
grid1.Col = i
grid1.Text = tmp$
Next i
Wend
End Function