MySQL Verbindung

Wie auf MySql und den ganzen Rest zugreifen ...

Re: MySQL Verbindung

Beitragvon yoda » Di 19. Okt 2010, 19:57

Hi,

versuch mal das

Code: Alles auswählen
FUNCTION make_connect() AS Boolean

  WITH $hConn
    .Type = "mysql"
    .Host = DB_server
    .Login = DB_user
    .Password = DB_passwort
    .Name = DB_name
  END WITH
  TRY $hConn.Open

  IF ERROR THEN
    Message(" (1) Kann Datenbank nicht öffnen.<br> Error= " & Error.Text & "<br><br> Im Menü '<font color=blau> Datei => Datenbank anlegen</font>' erst eine Datenbank erstellen !")
 
    RETURN FALSE
  END IF
  RETURN TRUE
END

PUBLIC SUB Button3_Click() 'Tag neu einlesen
DIM sql AS String
DIM azeit AS Variant
DIM ueberst AS Variant
DIM ueberst_tmp AS Variant
DIM resultP AS Result
DIM v_zeile AS Integer
DIM gesamt AS Float
DIM conn AS NEW Connection
DIM tmp AS String

      gesamt = 0
      azeit = 0
      ueberst_tmp = TextBox6.text + TextBox7.text
  IF make_connect() = TRUE THEN
 
    IF ERROR THEN
      Message("Kann Datenbank nicht öffnen. \nError= " & Error.Text)
    END IF
   
   sql = "select * from std where jahr='" & DateChooser2.Year & "' and mon='" & DateChooser2.Month & "' and tag='" & DateChooser2.Day & "' order by tag DESC"
   resultP = $hConn.Exec(sql)
   IF resultP.Available THEN
      resultP.MoveFirst
   
      WITH ColumnView2
        .Columns.Count = 9
        .Columns[0].Width = 10
        .Columns[0].Text = "ID"
        .Columns[1].Width = 60
        .Columns[1].Text = "User"
        .Columns[2].Width = 2
        .Columns[2].Text = "Tag"
        .Columns[3].Width = 2
        .Columns[3].Text = "Monat"
        .Columns[4].Width = 4
        .Columns[4].Text = "Jahr"
        .Columns[5].Width = 60
        .Columns[5].Text = "Kunde"
        .Columns[6].Width = 50
        .Columns[6].Text = "Arbeit"
        .Columns[7].Width = 60
        .Columns[7].Text = "Zeit"
        .Columns[8].Width = 100
        .Columns[8].Text = "Bemerkung"
 
      END WITH
      ColumnView2.Clear()
 
      FOR v_zeile = 0 TO resultP.Count - 1
        IdP.Add(Str(v_zeile))
        IdP[v_zeile] = resultP!id
          ColumnView2.Add(v_zeile, resultP!id)
          ColumnView2[v_zeile][1] = resultP!user
          ColumnView2[v_zeile][2] = resultP!tag
          ColumnView2[v_zeile][3] = resultP!mon
          ColumnView2[v_zeile][4] = resultP!jahr
          ColumnView2[v_zeile][5] = resultP!kd
          ColumnView2[v_zeile][6] = resultP!arbeit
          ColumnView2[v_zeile][7] = resultP!azeit
          ColumnView2[v_zeile][8] = resultP!bemerk
         
         
          gesamt = gesamt + resultP!azeit
          resultP.MoveNext
         
         
          TextLabel5.text = gesamt
         
      NEXT
    ELSE
        ColumnView2.Clear()
    ENDIF
   TRY $hConn.Close
   
   
ENDIF

END



ich hoffe es hilft dir weiter

mfg Yoda
yoda
Site Admin
 
Beiträge: 423
Registriert: Mo 2. Jan 2006, 22:35
Wohnort: bei Göttinge

Zurück zu Datenbankzugriff

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast