我有代码:
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
我想在MSSQL数据库中写入与“Klienci_NC.adres”列中的地址相关的更多数据,使用& Adres_niceform& VBScript看起来像这样:
myCommand.CommandText = "UPDATE Klienci_NC SET Klienci_NC.adres = '" & & Adres_niceform' 'WHERE Klienci_NC.ID =' "& ID_zmienna &" ' "
然而,使用
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
仅执行第一行:
myCommand.CommandText =“UPDATE Klienci_NC SET Klienci_NC.Klient ='”& &安培; Klient_niceform''WERE Klienci_NC.ID ='“& ID_zmienna&” '“
如何加入剧本:
myCommand.CommandText = "UPDATE Klienci_NC SET Klienci_NC.adres = '" & & Adres_niceform' 'WHERE Klienci_NC.ID =' "& ID_zmienna &" ' "
这两个工作得当吗?
答案 0 :(得分:1)
结合两种陈述?
myCommand.CommandText = "UPDATE Klienci_NC SET Klienci_NC.Klient = '" & Klient_niceform & "',Klienci_NC.adres = '" & Adres_niceform &"' WHERE Klienci_NC.ID ='" & ID_zmienna &"'"