I have the code:
Dim conn, SQL, rs
Const DB_CONNECT_STRING = "Provider = SQLOLEDB.1; Data Source = DJ-PC; Initial Catalog = Baza_NC; user id = 'user_baza_nc'; password = 'Password1'"
Set myConn = CreateObject ( "ADODB.Connection")
Set MyCommand = CreateObject ( "ADODB.Command")
myConn.Open DB_CONNECT_STRING
Set myCommand.ActiveConnection = myConn
myCommand.CommandText = "UPDATE Klienci_NC SET Klienci_NC.Klient = '" & & Klient_niceform' 'WHERE Klienci_NC.ID =' "& ID_zmienna &" ' "
myCommand.Execute
myConn.Close
I would like to write to MSSQL database further data relating to the address in the column "Klienci_NC.adres" using & Adres_niceform & the VBScript looks like this:
myCommand.CommandText = "UPDATE Klienci_NC SET Klienci_NC.adres = '" & & Adres_niceform' 'WHERE Klienci_NC.ID =' "& ID_zmienna &" ' "
however, using
Dim conn, SQL, rs
Const DB_CONNECT_STRING = "Provider = SQLOLEDB.1; Data Source = DJ-PC; Initial Catalog = Baza_NC; user id = 'user_baza_nc'; password = 'Password1'"
Set myConn = CreateObject ( "ADODB.Connection")
Set MyCommand = CreateObject ( "ADODB.Command")
myConn.Open DB_CONNECT_STRING
Set myCommand.ActiveConnection = myConn
myCommand.CommandText = "UPDATE Klienci_NC SET Klienci_NC.Klient = '" & & Klient_niceform' 'WHERE Klienci_NC.ID =' "& ID_zmienna &" ' "
myCommand.CommandText = "UPDATE Klienci_NC SET Klienci_NC.adres = '" & & Adres_niceform' 'WHERE Klienci_NC.ID =' "& ID_zmienna &" ' "
myCommand.Execute
myConn.Close
It is performed only the first line:
myCommand.CommandText = "UPDATE Klienci_NC SET Klienci_NC.Klient = '" & & Klient_niceform' 'WHERE Klienci_NC.ID =' "& ID_zmienna &" ' "
How to join the script:
myCommand.CommandText = "UPDATE Klienci_NC SET Klienci_NC.adres = '" & & Adres_niceform' 'WHERE Klienci_NC.ID =' "& ID_zmienna &" ' "
the two worked properly?
update table set col1 = val1, col2 = val2 where ...but your code is possibly also vulnerable to SQL injection attacks and you should use ADODB command parameters to inject the values instead of raw concatenation. I don't quite remember the proper syntax though (which is why this is a comment and not an answer).