vbscript to read and write or update an Access mdb database
how to read and write an Access Database in vbscript includes an update function: if the Entry exists Records are updated if not a new entry is generated
read
reads an table of an Access Database you have to fill in the right Field names: rs.Fields("Spalte1")
Set conn = CreateObject("ADODB.Connection")
' Connect to the database
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test.mdb"
conn.Open strConnect
StrSQL = "Select * from daten"
Set rs = conn.Execute(StrSQL)
Do While not rs.EOF
wscript.echo "Spalte1:" & rs.Fields("Spalte1") & " Spalte2:"& rs.Fields("Spalte2")
rs.MoveNext
Loop
Update or add new
the sub function updateornew searches Row1 for an existing Variable:
if exists the entry is updated if not it will make a new entry in the database
the function addnewentry always makes a new entry in the database
'''''''''''''''''''''''''''''''''''''''''''''''''''''
'Main Program
'''''''''''''''''''''''''''''''''''''''''''''''''''''
'call addnewentry("Row1entry","Row2entry","Row3entry")
call updateornew("Row1 new or update eintry","Row2","Row3")
'''''''''''''''''''''''''''''''''''''''''''''''''''''