BlitzData-Frage

Übersicht BlitzBasic Allgemein

Neue Antwort erstellen

DAK

Betreff: BlitzData-Frage

BeitragFr, Feb 22, 2008 7:38
Antworten mit Zitat
Benutzer-Profile anzeigen
Kennt sich jemand mit BlitzData (http://www.radioactivegamer.co...ataupd.zip) aus und kann mir sagen, warum folgender code nicht funktioniert:
Code: [AUSKLAPPEN]
Include "BD_Constants.bb"
Type user
   Field vorname$, nachname$, klasse$, password$
End Type
Global uid
instream = OpenFile("schüler.txt")
Print "Select mode:"
Print "1 = only read-out"
Print "2 = read-out + create pasword-file"
Print "3 = read-out + create pasword-file + upload data"
mode = Input()
Print "Starting read-out..."
While Not Eof(instream)
   ln$ = ReadLine(instream)
   u.user = New user
   u\nachname$ = Left(ln$, Instr(ln$, " ")-1)
   ln$ = Right(ln$, Len(ln$)-Instr(ln$, " "))
   u\klasse$ = Right(ln$, 2)
   u\vorname$ = Left(ln$, Len(ln$)-3)
   If mode = 1 Then
      Print "v:'"+u\vorname$+"'"
      Print "n:'"+u\nachname$+"'"
      Print "k:'"+u\klasse$+"'"
   EndIf
   u\password$ = createpassword$()
   If KeyHit(1) Then End
Wend
Print "Read-out ended."
Print "Create password file..."
If mode=1 Then WaitKey:End
CloseFile instream
outstream = WriteFile("passes.txt")
For u.user = Each user
   uname$ = Lower(Left(u\vorname$,1)+u\nachname$)+u\klasse$
   WriteLine outstream, uname$+":"+u\password$
Next
CloseFile outstream
Print "Password file created."
If mode = 2 Then WaitKey:End
Print "Conecting to database..."
Delay 10
mysql=BD_OpenDatabase(databasename,datenbank,username,password,1)
Stop
If mysql = -1  Then
   RuntimeError "Could not conect to database."
EndIf
Print "Conected."
Print "Parsing data..."
uid = 19
For u.user = Each user
   uid = uid+1
   If uid=20 Then
      x = BD_SQLQuery(createout(Handle(u.user)))
      
   EndIf
Next
Print "Parsed."
Print "Finished."
Print "Press any key..."
FlushKeys
WaitKey
End

Function createout(hand)
   u.user = Object.user(hand)
   out$ = "INSERT into test (uid, pid, username, first_name, last_name$,
   out$ = out$+" password, crdate, cruser_id) VALUES ("+uid+", 28, '"
   out$ = out$+Lower(Left(u\vorname$,1)+u\nachname$)+u\klasse$+"', '"
   out$ = out$+u\vorname$+"' , '"+u\nachname$+"', '"+u\password$+"', "
   out$ = out$+"1203604200, 14)"
   Return out$
End Function

Function createpassword$()
   pass$ = ""
   For i = 1 To 8
      typ = Rand(1,3)
      Select typ
      Case 1
         code = Rand(48,57)
      Case 2
         code = Rand(65,90)
      Case 3
         code = Rand(97,122)
      End Select
      pass$ = pass$ + Chr(code)
   Next
   Return pass$
End Function


hab natürlich in meinem programm das zeug bei DB_OpenDatabase angepasst...
Gewinner der 6. und der 68. BlitzCodeCompo

Neue Antwort erstellen


Übersicht BlitzBasic Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group