c# - Updating database gives "The multi-part identifier could not be bound." Error -


i'm trying update bookingid in counselordb table. it's null. cid string contains predefined counselorid.

the error i'm getting multi-part identifier "x" not bound; x being cid.

thank you.

 using (sqlconnection connection = new sqlconnection(connectionstring))     {         string sql = string.format("update counselordb set bookingid = @bookingid counselorid = " + cid);         sqlcommand cmd = new sqlcommand(sql, connection);         cmd.commandtype = commandtype.text;         cmd.connection = connection;         cmd.parameters.addwithvalue("@bookingid", getbookingid());         connection.open();         cmd.executenonquery();     } 

you try this:

using (sqlconnection connection = new sqlconnection(connectionstring)) {     string sql = "update counselordb "+                  "set bookingid = @bookingid "+                  "where counselorid = @counselorid";      sqlcommand cmd = new sqlcommand(sql, connection);     cmd.commandtype = commandtype.text;     cmd.connection = connection;     cmd.parameters.addwithvalue("@bookingid", getbookingid());     cmd.parameters.addwithvalue("@counselorid", cid);     connection.open();     cmd.executenonquery(); } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -