Mysql Insert + Update Data

  • hallo ,

    ich beschäftige mich gerade mit der MySQL UDF - mit libmySQL.dll!

    hier benötige ich ein paar beispiele für eine insert bzw. update in eine tabelle!

    habe mal meine vorherige anfrage als zitat eingefügt!

    kann mir da jemand mit paar beispielen helfen? :?:

    danke

    gruß gmmg


    6 Mal editiert, zuletzt von gmmg (20. September 2010 um 20:17)

  • Hier ein Beispiel aus dem Zitat:

    Spoiler anzeigen


    INSERT INTO table (a,b,c) VALUES (1,2,3)
    ON DUPLICATE KEY UPDATE c=1;

    UPDATE table SET c=1 WHERE a=1;

    Sonst muß ich aber BugFix rechtgeben.

    MfG
    Der_Doc

  • hallo,

    danke euch beiden!

    "progandy" hat ja die funktionen genannt, die ich da einsetzen soll!
    da ich mit mysql und autoit nocht nichts gemacht habe, muss ich mich da erst einlesen!

    beispiele, wie man die funktion bedient, helfen da meist einfach weiter ...

    gruß gmmg

  • So in etwa:

    [autoit]

    ...
    $Benutzername_sicher = _MySQL_Real_Escape_String($hConnection, $Benutzername)
    ...
    _MySQL_Real_Query($hConnection, "INSERT ... SET `benutzer`='" & $Benutzername_sicher & "'")

    [/autoit]
  • so, hier mein beispiel!

    Spoiler anzeigen
    [autoit][/autoit] [autoit][/autoit] [autoit]

    #Include <File.au3>
    #include <mysql.au3>
    #include <array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    DIM $aRecords

    [/autoit] [autoit][/autoit] [autoit]

    $file = "C:\test.txt"

    [/autoit] [autoit][/autoit] [autoit]

    If Not _FileReadToArray($file,$aRecords) Then
    MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ; db verbindungsvariablen
    $ipadd = "127.0.0.1"
    $sname = "root"
    $spasswort = ""
    $db = "otmailid"

    [/autoit] [autoit][/autoit] [autoit]

    _MySQL_InitLibrary()
    If @error Then Exit MsgBox(0, "Fehler", "libmysql.dll nicht gefunden")

    [/autoit] [autoit][/autoit] [autoit]

    $MysqlConn = _MySQL_Init()

    [/autoit] [autoit][/autoit] [autoit]

    $connected = _MySQL_Real_Connect($MysqlConn,$ipadd,$sname,$spasswort,$db)
    If $connected = 0 Then
    $errno = _MySQL_errno($MysqlConn)
    MsgBox(0,"Fehler","Login Server ist nicht Erreichbar")
    Exit
    Endif

    [/autoit] [autoit][/autoit] [autoit]

    For $x = 2 to $aRecords[0]
    ;Msgbox(0,'Record:', $aRecords[$x])

    [/autoit] [autoit][/autoit] [autoit]

    $s_Row_txt_t1 = StringSplit($aRecords[$x], ";")

    [/autoit] [autoit][/autoit] [autoit]

    $s_Row_txt = StringReplace($aRecords[$x], ";", "','")

    [/autoit] [autoit][/autoit] [autoit]

    $s_Row_txt = "'" & $s_Row_txt & "'"
    MsgBox(0,"",$s_Row_txt)

    [/autoit] [autoit][/autoit] [autoit]

    ;Local $sQuery = "INSERT INTO test (A,B,C) VALUES (" & $s_Row_txt & ")"
    Local $sQuery = "INSERT INTO test (A,B,C) VALUES (" & $s_Row_txt & ")" & _
    " ON DUPLICATE KEY UPDATE `B` = (" & "'" & $s_Row_txt_t1[2] & "'" & ") , `C` = (" & "'" & $s_Row_txt_t1[3] & "'" & ")"
    MsgBox(0,"",$sQuery)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _MySQL_Real_Query($MysqlConn, $sQuery)

    [/autoit] [autoit][/autoit] [autoit]

    Local $res = _MySQL_Store_Result($MysqlConn)
    Local $row1 = 0

    [/autoit] [autoit][/autoit] [autoit]

    If $res<>0 Then
    $row1 = _MySQL_Fetch_Row_StringArray($res)
    _MySQL_Free_Result($res)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Next

    [/autoit] [autoit][/autoit] [autoit]

    ;MsgBox(0,"","einfügen in tabelle fertig",5)

    [/autoit] [autoit][/autoit] [autoit]

    _MySQL_Close($MysqlConn)

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    kann man da noch was verbessern?

    zur info, möchte täglich die test.txt einlesen!

    neue datensätze sollen angefügt werden, vorhandene (A = primary key) sollen mit einem update befehl geändert werden!
    wie kann ich jetzt dem ganzen eine updatebefehl hinzufügen?

    Local $sQuery = "INSERT INTO test (A,B,C) VALUES (" & $s_Row_txt & ")"

    komme hier jetzt gerade nicht weiter ... wie baue ich mir die query auf?

    meine gedanken ...
    ich lese die txt in ein array u. füge die daten der tabelle hinzu, wenn jetzt ein datensatz (spalte A = primary key) vorhanden ist, soll es ein update auf diesen datensatz ( Spalte B,C) geben

    update ....
    folgend funktioniert es :

    [autoit]


    Local $sQuery = "INSERT INTO test (A,B,C) VALUES (" & $s_Row_txt & ")" & _
    " ON DUPLICATE KEY UPDATE `B` = (" & "'" & $s_Row_txt_t1[2] & "'" & ") , `C` = (" & "'" & $s_Row_txt_t1[3] & "'" & ")"
    MsgBox(0,"",$sQuery)

    [/autoit][autoit][/autoit][autoit][/autoit]

    gibt es noch vorschläge zur verbesserung?

    gruß gmmg

  • hallo zusammen,

    folgend nochmal das script!

    Spoiler anzeigen
    [autoit][/autoit] [autoit][/autoit] [autoit]

    #Include <File.au3>
    #include <mysql.au3>
    #include <array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    DIM $aRecords

    [/autoit] [autoit][/autoit] [autoit]

    $file = "C:\otmailid.txt"

    [/autoit] [autoit][/autoit] [autoit]

    If Not _FileReadToArray($file,$aRecords) Then
    MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ; db verbindungsvariablen
    $ipadd = "127.0.0.1"
    $sname = "root"
    $spasswort = ""
    $db = "otmailid"

    [/autoit] [autoit][/autoit] [autoit]

    _MySQL_InitLibrary()
    If @error Then Exit MsgBox(0, "Fehler", "libmysql.dll nicht gefunden")

    [/autoit] [autoit][/autoit] [autoit]

    $MysqlConn = _MySQL_Init()

    [/autoit] [autoit][/autoit] [autoit]

    $connected = _MySQL_Real_Connect($MysqlConn,$ipadd,$sname,$spasswort,$db)
    If $connected = 0 Then
    $errno = _MySQL_errno($MysqlConn)
    MsgBox(0,"Fehler","Login Server ist nicht Erreichbar")
    Exit
    Endif

    [/autoit] [autoit][/autoit] [autoit]

    For $x = 2 to $aRecords[0]
    Msgbox(0,'Record:', $aRecords[$x])

    [/autoit] [autoit][/autoit] [autoit]

    $s_Row_txt_t1 = StringSplit($aRecords[$x], ";")
    ;$s_Row_txt_t1[1] contains the first split
    ;MsgBox(0,"",$s_Row_txt_t1[1])
    ;MsgBox(0,"",$s_Row_txt_t1[2])
    ;MsgBox(0,"",$s_Row_txt_t1[3])

    [/autoit] [autoit][/autoit] [autoit]

    $s_Row_txt = StringReplace($aRecords[$x], ";", "','")

    [/autoit] [autoit][/autoit] [autoit]

    $s_Row_txt = "'" & $s_Row_txt & "'"
    ;MsgBox(0,"",$s_Row_txt)

    [/autoit] [autoit][/autoit] [autoit]

    ;Local $sQuery = "INSERT INTO test (A,B,C) VALUES (" & $s_Row_txt & ")" & "ON DUPLICATE KEY UPDATE (`C`) VALUES (" & $s_Row_txt_t1[3] & ")"
    Local $sQuery = "INSERT INTO otmailid (BU_NR,ERF_DAT,SB_MA,AG_NR,KU_NR,MAILADRESSE,TYP) VALUES (" & $s_Row_txt & ")" & _
    " ON DUPLICATE KEY UPDATE `ERF_DAT` = (" & "'" & $s_Row_txt_t1[2] & "'" & ") ," & _
    "`SB_MA` = (" & "'" & $s_Row_txt_t1[3] & "'" & ")," & _
    "`AG_NR` = (" & "'" & $s_Row_txt_t1[4] & "'" & ")," & _
    "`KU_NR` = (" & "'" & $s_Row_txt_t1[5] & "'" & ")," & _
    "`MAILADRESSE` = (" & "'" & $s_Row_txt_t1[6] & "'" & ")," & _
    "`TYP` = (" & "'" & $s_Row_txt_t1[7] & "'" & ")"
    ;MsgBox(0,"",$sQuery)

    [/autoit] [autoit][/autoit] [autoit]

    _MySQL_Real_Query($MysqlConn, $sQuery)

    [/autoit] [autoit][/autoit] [autoit]

    Local $res = _MySQL_Store_Result($MysqlConn)
    Local $row1 = 0
    ;a=VALUES(a),

    [/autoit] [autoit][/autoit] [autoit]

    If $res<>0 Then
    $row1 = _MySQL_Fetch_Row_StringArray($res)
    _MySQL_Free_Result($res)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Next

    [/autoit] [autoit][/autoit] [autoit]

    MsgBox(0,"","einfügen in tabelle fertig",5)

    [/autoit] [autoit][/autoit] [autoit]

    _MySQL_Close($MysqlConn)

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    was kann man am quelltext noch verbessern?

    gruß gmmg ;)

  • Diesen Teil kannst du entfernen, da eine INSERT-Anweisung keine Ergebnismenge zurückgibt:

    [autoit]

    Local $res = _MySQL_Store_Result($MysqlConn)
    Local $row1 = 0
    ;a=VALUES(a),

    [/autoit][autoit][/autoit][autoit]

    If $res<>0 Then
    $row1 = _MySQL_Fetch_Row_StringArray($res)
    _MySQL_Free_Result($res)
    EndIf

    [/autoit][autoit][/autoit][autoit][/autoit]


    Am besten rufst du am Ende auch _MySQL_UnInitLibrary auf um Speicher der MySQL-DLL freizugeben.

    Außerdem solltest du die Eingabedaten SQL-sicher machen, damit da keine Probleme auftreten:

    [autoit]


    $s_Row_txt_t1 = StringSplit($aRecords[$x], ";")
    $s_Row_txt=''
    For $i = 1 To $s_Row_txt_t1[0]
    $s_Row_txt_t1[$i] = _MySQL_Real_Escape_String($MysqlConn, $s_Row_txt_t1[$i])
    $s_Row_txt = "'" & $s_Row_txt_t1[$i] & "' ,"
    Next
    $s_Row_txt = StringTrimRight($s_Row_txt, 1)

    [/autoit]

    Einmal editiert, zuletzt von progandy (15. Februar 2010 um 11:03)

  • hallo progandy,

    danke für die info!

    kann keine func _MySQL_UnInitLibrary finden, ist es eventuell folgende?

    _MySQL_EndLibrary()

    wo füge ich das folgende script ein? warum das StringTrimRight?

    [autoit]


    $s_Row_txt_t1 = StringSplit($aRecords[$x], ";")
    $s_Row_txt=''
    For $i = 1 To $s_Row_txt_t1[0]
    $s_Row_txt_t1[$i] = _MySQL_Real_Escape_String($MysqlConn, $s_Row_txt_t1[$i])
    $s_Row_txt = "'" & $s_Row_txt_t1[$i] & "' ,"
    Next
    $s_Row_txt = StringTrimRight($s_Row_txt, 1)

    [/autoit]

    versteh das gerade nicht ganz ... kannst du mir das erklären?

    hier nochmal mein for next abschnitt ...

    [autoit][/autoit][autoit][/autoit][autoit]

    For $x = 2 to $aRecords[0]
    Msgbox(0,'Record:', $aRecords[$x])

    [/autoit][autoit][/autoit][autoit]

    $s_Row_txt_t1 = StringSplit($aRecords[$x], ";") ; split für ON DUPLICATE KEY UPDATE werte

    [/autoit][autoit][/autoit][autoit]

    $s_Row_txt = StringReplace($aRecords[$x], ";", "','") ; anpassen des eingelesenen strings

    [/autoit][autoit][/autoit][autoit]

    $s_Row_txt = "'" & $s_Row_txt & "'"
    ;MsgBox(0,"",$s_Row_txt)

    [/autoit][autoit][/autoit][autoit]

    Local $sQuery = "INSERT INTO otmailid (BU_NR,ERF_DAT,SB_MA,AG_NR,KU_NR,MAILADRESSE,TYP) VALUES (" & $s_Row_txt & ")" & _
    " ON DUPLICATE KEY UPDATE `ERF_DAT` = (" & "'" & $s_Row_txt_t1[2] & "'" & ") ," & _
    "`SB_MA` = (" & "'" & $s_Row_txt_t1[3] & "'" & ")," & _
    "`AG_NR` = (" & "'" & $s_Row_txt_t1[4] & "'" & ")," & _
    "`KU_NR` = (" & "'" & $s_Row_txt_t1[5] & "'" & ")," & _
    "`MAILADRESSE` = (" & "'" & $s_Row_txt_t1[6] & "'" & ")," & _
    "`TYP` = (" & "'" & $s_Row_txt_t1[7] & "'" & ")"
    ;MsgBox(0,"",$sQuery)

    [/autoit][autoit][/autoit][autoit]

    _MySQL_Real_Query($MysqlConn, $sQuery)

    [/autoit][autoit][/autoit][autoit]

    Next

    [/autoit][autoit][/autoit][autoit]

    ; Verbindung beenden
    _MySQL_Close($MysqlConn)
    ; MYSQL beenden
    _MySQL_EndLibrary()

    [/autoit][autoit][/autoit][autoit][/autoit]


    gruß gmmg

    2 Mal editiert, zuletzt von gmmg (15. Februar 2010 um 13:36)

  • Ähm, ja EndLibrary ;)
    Du musst Zeile 4-9 aus dem Auschnitt ersetzen.
    Das StringTrimRight wird benötigt, da in der Schleife immer ein Komma ans Ende gehängt wird. Nach dem letzten Wert darf aber keines mehr kommen, sonst stimmt die Syntax nicht mehr ;)

  • funktioniert so nicht!

    $s_Row_txt = StringTrimRight($s_Row_txt, 1)

    string = BU_NR,ERF_DAT,SB_MA,AG_NR,KU_NR,MAILADRESSE,TYP

    $s_Row_txt --> gibt mir nur den letzten eintrag aus dem string, also den wert, der bei TYP steht

    [autoit]


    For $x = 2 to $aRecords[0]
    ;Msgbox(0,'Record:', $aRecords[$x])

    [/autoit][autoit][/autoit][autoit]

    $s_Row_txt_t1 = StringSplit($aRecords[$x], ";")
    $s_Row_txt=''
    For $i = 1 To $s_Row_txt_t1[0]
    $s_Row_txt_t1[$i] = _MySQL_Real_Escape_String($MysqlConn, $s_Row_txt_t1[$i])
    $s_Row_txt = "'" & $s_Row_txt_t1[$i] & "' ,"
    Next
    $s_Row_txt = StringTrimRight($s_Row_txt, 1)

    [/autoit][autoit][/autoit][autoit]

    Local $sQuery = "INSERT INTO otmailid (BU_NR,ERF_DAT,SB_MA,AG_NR,KU_NR,MAILADRESSE,TYP) VALUES (" & $s_Row_txt & ")" & _
    " ON DUPLICATE KEY UPDATE `ERF_DAT` = (" & "'" & $s_Row_txt_t1[2] & "'" & ") ," & _
    "`SB_MA` = (" & "'" & $s_Row_txt_t1[3] & "'" & ")," & _
    "`AG_NR` = (" & "'" & $s_Row_txt_t1[4] & "'" & ")," & _
    "`KU_NR` = (" & "'" & $s_Row_txt_t1[5] & "'" & ")," & _
    "`MAILADRESSE` = (" & "'" & $s_Row_txt_t1[6] & "'" & ")," & _
    "`TYP` = (" & "'" & $s_Row_txt_t1[7] & "'" & ")"
    ;MsgBox(0,"",$sQuery)

    [/autoit][autoit][/autoit][autoit]

    _MySQL_Real_Query($MysqlConn, $sQuery)

    [/autoit][autoit][/autoit][autoit]

    Next

    [/autoit]

    gruß gmmg

  • Man, hab vergessen, &= statt = zu schreiben.

    Spoiler anzeigen
    [autoit]

    For $x = 2 to $aRecords[0]
    ;Msgbox(0,'Record:', $aRecords[$x])

    [/autoit] [autoit][/autoit] [autoit]

    $s_Row_txt_t1 = StringSplit($aRecords[$x], ";")
    $s_Row_txt=''
    For $i = 1 To $s_Row_txt_t1[0]
    $s_Row_txt_t1[$i] = _MySQL_Real_Escape_String($MysqlConn, $s_Row_txt_t1[$i])
    $s_Row_txt &= "'" & $s_Row_txt_t1[$i] & "' ,"
    Next
    $s_Row_txt = StringTrimRight($s_Row_txt, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Local $sQuery = "INSERT INTO otmailid (BU_NR,ERF_DAT,SB_MA,AG_NR,KU_NR,MAILADRESSE,TYP) VALUES (" & $s_Row_txt & ")" & _
    " ON DUPLICATE KEY UPDATE `ERF_DAT` = (" & "'" & $s_Row_txt_t1[2] & "'" & ") ," & _
    "`SB_MA` = (" & "'" & $s_Row_txt_t1[3] & "'" & ")," & _
    "`AG_NR` = (" & "'" & $s_Row_txt_t1[4] & "'" & ")," & _
    "`KU_NR` = (" & "'" & $s_Row_txt_t1[5] & "'" & ")," & _
    "`MAILADRESSE` = (" & "'" & $s_Row_txt_t1[6] & "'" & ")," & _
    "`TYP` = (" & "'" & $s_Row_txt_t1[7] & "'" & ")"
    ;MsgBox(0,"",$sQuery)

    [/autoit] [autoit][/autoit] [autoit]

    _MySQL_Real_Query($MysqlConn, $sQuery)

    [/autoit] [autoit][/autoit] [autoit]

    Next

    [/autoit]
  • danke, so funktioniert es jetzt ;)

    kannst du mir nochmal den abschnitt erklären, hab das nicht ganz verstanden!

    [autoit]


    $s_Row_txt_t1 = StringSplit($aRecords[$x], ";")
    $s_Row_txt=''
    For $i = 1 To $s_Row_txt_t1[0]
    $s_Row_txt_t1[$i] = _MySQL_Real_Escape_String($MysqlConn, $s_Row_txt_t1[$i])
    $s_Row_txt &= "'" & $s_Row_txt_t1[$i] & "' ,"
    Next
    $s_Row_txt = StringTrimRight($s_Row_txt, 1)

    [/autoit]

    hier nochmal das komplette script ..

    Spoiler anzeigen
    [autoit][/autoit] [autoit][/autoit] [autoit]

    #Include <File.au3>
    #include <mysql.au3>
    #include <array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    DIM $aRecords

    [/autoit] [autoit][/autoit] [autoit]

    $file = "C:\otmailid.txt"

    [/autoit] [autoit][/autoit] [autoit]

    If Not _FileReadToArray($file,$aRecords) Then
    MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;$s_Row1 = StringReplace($aRecords[1],"-","_")
    ;$s_Row1 = StringReplace($s_Row1,"/","_")
    ;$s_Row1 = StringReplace($s_Row1, ";", " TEXT|")
    ;$s_Row1 = $s_Row1 & " TEXT"
    ;$s_Row1 = $s_Row1
    ;MsgBox(0,"",$s_Row1)

    [/autoit] [autoit][/autoit] [autoit]

    ; db verbindungsvariablen
    $ipadd = "127.0.0.1"
    $sname = "root"
    $spasswort = "root"
    $db = "otmailid"

    [/autoit] [autoit][/autoit] [autoit]

    _MySQL_InitLibrary()
    If @error Then Exit MsgBox(0, "Fehler", "libmysql.dll nicht gefunden")

    [/autoit] [autoit][/autoit] [autoit]

    $MysqlConn = _MySQL_Init()

    [/autoit] [autoit][/autoit] [autoit]

    $connected = _MySQL_Real_Connect($MysqlConn,$ipadd,$sname,$spasswort,$db)
    If $connected = 0 Then
    $errno = _MySQL_errno($MysqlConn)
    MsgBox(0,"Fehler","Login Server ist nicht Erreichbar")
    Exit
    Endif

    [/autoit] [autoit][/autoit] [autoit]

    For $x = 2 to $aRecords[0]
    ;Msgbox(0,'Record:', $aRecords[$x])

    [/autoit] [autoit][/autoit] [autoit]

    $s_Row_txt_t1 = StringSplit($aRecords[$x], ";")
    $s_Row_txt=''
    For $i = 1 To $s_Row_txt_t1[0]
    $s_Row_txt_t1[$i] = _MySQL_Real_Escape_String($MysqlConn, $s_Row_txt_t1[$i])
    $s_Row_txt &= "'" & $s_Row_txt_t1[$i] & "' ,"
    Next
    $s_Row_txt = StringTrimRight($s_Row_txt, 1)

    [/autoit] [autoit][/autoit] [autoit]

    ;MsgBox(0,"",$s_Row_txt)

    [/autoit] [autoit][/autoit] [autoit]

    Local $sQuery = "INSERT INTO otmailid (BU_NR,ERF_DAT,SB_MA,AG_NR,KU_NR,MAILADRESSE,TYP) VALUES (" & $s_Row_txt & ")" & _
    " ON DUPLICATE KEY UPDATE `ERF_DAT` = (" & "'" & $s_Row_txt_t1[2] & "'" & ") ," & _
    "`SB_MA` = (" & "'" & $s_Row_txt_t1[3] & "'" & ")," & _
    "`AG_NR` = (" & "'" & $s_Row_txt_t1[4] & "'" & ")," & _
    "`KU_NR` = (" & "'" & $s_Row_txt_t1[5] & "'" & ")," & _
    "`MAILADRESSE` = (" & "'" & $s_Row_txt_t1[6] & "'" & ")," & _
    "`TYP` = (" & "'" & $s_Row_txt_t1[7] & "'" & ")"
    ;MsgBox(0,"",$sQuery)

    [/autoit] [autoit][/autoit] [autoit]

    _MySQL_Real_Query($MysqlConn, $sQuery)

    [/autoit] [autoit][/autoit] [autoit]

    Next

    [/autoit] [autoit][/autoit] [autoit]

    MsgBox(0,"","einfügen in tabelle fertig",5)

    [/autoit] [autoit][/autoit] [autoit]

    ; Verbindung beenden
    _MySQL_Close($MysqlConn)
    ; MYSQL beenden
    _MySQL_EndLibrary()

    [/autoit]

    :thumbup:

    gruß gmmg

  • Bitte, ich habs dir kommentiert

    Spoiler anzeigen
    [autoit]

    $s_Row_txt_t1 = StringSplit($aRecords[$x], ";")
    ; den Record in die einzelnen Felder teilen

    [/autoit] [autoit][/autoit] [autoit]

    $s_Row_txt=''
    ; Variable füe gesamten Text leeren

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To $s_Row_txt_t1[0]
    ; für jedes Feld Befehle ausführen

    [/autoit] [autoit][/autoit] [autoit]

    $s_Row_txt_t1[$i] = _MySQL_Real_Escape_String($MysqlConn, $s_Row_txt_t1[$i])
    ; Feldinhalt MySQL-sicher machen

    [/autoit] [autoit][/autoit] [autoit]

    $s_Row_txt &= "'" & $s_Row_txt_t1[$i] & "' ,"
    ; an des Gesamttext ein Anführungszeichen , den gesicherten Text, ein Anführungszeichen und ein Komma anhängen

    [/autoit] [autoit][/autoit] [autoit]

    Next
    ; wiederholen

    [/autoit] [autoit][/autoit] [autoit]

    $s_Row_txt = StringTrimRight($s_Row_txt, 1)
    ; Das letzte Komma vom Gesamtstring entfernen

    [/autoit]
  • @progandy,

    ich muss mein thema nochmal aufgreifen!

    ich habe probleme in die tabelle zu schreiben, wenn der feldname ein bindestrich enthält z.b. BU-NR!
    ist das in mysql so definiert? kann ich mir nicht vorstellen, da es per odbc aus access heraus funktioniert.!

    gruß gmmg

  • Die DLL sollte damit keine Probleme haben, wenn du den Feldnamen richtig maskierst, also `Feld-Name!` Du musst schon auf die richtige Syntax achten ;)

  • danke,

    daran lag es, hatte die hochstriche ` xx` nur bei "ON DUPLICATE KEY" drin ...

    wie kann ich eine leerzeile in einer txt am ende der einträge entfernen?

    gruß gmmg ;)