Hi,I have a problem with SQL parameters.INSERT INTO Material (MaterialNr,Bezeichnung,Mandant) VALUES (@MaterialNr, @Bezeichnung, @Mandant)
Executing this statement results in the error Must declare the scalar variable "@MaterialNr".If I declare the variable before...DECLARE @MaterialNr varchar(4000), @Bezeichnung varchar(4000), @Mandant varchar(4000)INSERT INTO Material (MaterialNr,Bezeichnung,Mandant) VALUES (@MaterialNr, @Bezeichnung, @Mandant)
...I get the error Cannot insert the value NULL into column 'MaterialNr', although OdbcCommand.Parameters is filled.If I use ? as parameter, it works. But I want to avoid that, because the final statement will look like this:UPDATE Material SET Bezeichnung=@Bezeichnung WHERE MaterialNr=@MaterialNr AND Mandant=@MandantIF (@@ROWCOUNT = 0) BEGIN INSERT INTO Material (MaterialNr,Bezeichnung,Mandant) VALUES (@MaterialNr, @Bezeichnung, @Mandant) END
If using ?, I would have to pass the same parameter multiple times.BTW: I use the Odbc classes, because the program should not require MS SQL Server.