I have a problem with update statement:
In column names i have characters like: % , []. In "insert into" statement I just put that in quotation marks and worked. But can't execute this update statement:
UPDATE WIG_BANKI
SET "Nazwa_spolki" = @BankNames,
"Pakiet" = @Packet,
"Udzial_w_portfelu[%]" = @ShareInPortfolio,
"Udzial_w_obrocie[%]" = @ShareOfTurnover,
"Wplyw_na_zmiane_indeksu[%]" = @ImpactOnChangeOfIndex,
"Zmiana_kursu_spolki[%]" = @ExchangeRate,
"Kurs[PLN]" = @PLN_ExchangeRate
WHERE "Nazwa_spolki" != @BankNames,
"Pakiet" != @Packet,
"Udzial_w_portfelu[%]" != @ShareInPortfolio,
"Udzial_w_obrocie[%]" != @ShareOfTurnover,
"Wplyw_na_zmiane_indeksu[%]" != @ImpactOnChangeOfIndex,
"Zmiana_kursu_spolki[%]" != @ExchangeRate,
"Kurs[PLN]" != @PLN_ExchangeRate
Then I execute the whole statement like this:
command.Parameters[Globals.columnsNamesArrayDB[i]].Value = array[i].ToString(); // here in for loop I set what is @BankNames etc.
command.CommandText = sbAllDataUpdate.ToString();
command.ExecuteNonQuery();
then this message error shows
System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near ','.
I have no idea how to correct it
For WHERE
you separate conditions with logical operators AND OR
WHERE "Nazwa_spolki" != @BankNames AND
"Pakiet" != @Packet AND
"Udzial_w_portfelu[%]" != @ShareInPortfolio AND
"Udzial_w_obrocie[%]" != @ShareOfTurnover AND
"Wplyw_na_zmiane_indeksu[%]" != @ImpactOnChangeOfIndex AND
"Zmiana_kursu_spolki[%]" != @ExchangeRate AND
"Kurs[PLN]" != @PLN_ExchangeRate
User contributions licensed under CC BY-SA 3.0