title image


Smiley Re: Mit Notes auf einen MYSQL Server zugreifen und Daten schreiben
Hy,



heir ein Script,



Cu

Martin



ODBC Script



(Options)

Option Public

Uselsx "*LSXODBC"

--------------------------------------------------------------

(Declarations)

Dim con As ODBCConnection

Dim qry As ODBCQuery

Dim result As ODBCResultSet

Dim defaultQuery As String



Dim Quelle As String

Dim Table As String



Dim LastName As String

Dim FirstName As String

Dim Strasse As String

Dim Plz As String

Dim Ort As String

Dim msg As String



--------------------------------------------------------------

Sub Initialize

Rem Die Variable Quelle enthält den Namen der ODBC Verbindung.

Quelle = "Verwaltung"

Rem Die Variable table enthält den Namen der eigentlichen Datenbank

Rem Bei mir eine einfache DBase Datenbank mit dem Namen adressen.dbf

table = "adressen"

LastName = ""

FirstName = ""



Call SQLSchreiben ()

Call SQLLesen ()

End Sub

--------------------------------------------------------------

Sub SQLLesen ()



Set con = New ODBCConnection

Set qry = New ODBCQuery

Set result = New ODBCResultSet

Set qry.Connection = con

Set result.Query = qry

defaultQuery = "SELECT * FROM " + table

qry.SQL = defaultQuery



con.ConnectTo(Quelle)

result.Execute

If result.IsResultSetAvailable Then

msg = "Adressen:" & Chr(10)

Do

result.NextRow

Rem GetValue (1, Firstname) holt den Wert aus der "1" Spalte der Tabelle und speichert Sie nach Firstname)

firstName = result.GetValue(1, FirstName)

lastName = result.GetValue(2, LastName)

msg = msg & Chr(10) & firstName & " " & lastName

Loop Until result.IsEndOfData

Messagebox msg,, "Adressen"

result.Close(DB_CLOSE)

Else

Messagebox "Kann nix finden"

Exit Sub

End If

con.Disconnect

End Sub

----------------------------------------------------------------------------------------

Sub SQLSchreiben ()



Set con = New ODBCConnection

Set qry = New ODBCQuery

Set result = New ODBCResultSet

Set qry.Connection = con

Set result.Query = qry

defaultQuery = "SELECT * FROM " + table

qry.SQL = defaultQuery



con.ConnectTo(Quelle)

result.Execute

status = result.AddRow

FirstName = Inputbox$("Vorname?")

Rem SetValue (1, Firstanme) schreibt den Wert von Firstname in die "1" Spalte der Tabelle

Call result.SetValue (1, FirstName)

LastName = Inputbox$("Name?")

Call result.SetValue (2, Lastname)

result.UpdateRow

result.Close(DB_CLOSE)

con.Disconnect

End Sub

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: