Scalar Variable


hello. i'm hoping can me. every time try error must declare scalar variable @albumid. doing wrong? in advance.
  public string getconnectionstring()      {        if (system.configuration.configurationmanager.connectionstrings["ensembecs.properties.settings.ensemblecsconnectionstring"] != null)          return system.configuration.configurationmanager.connectionstrings["ensembecs.properties.settings.ensemblecsconnectionstring"].tostring();        else          throw new exception("please define connectionstring web.config");      }      public int insertalbum(sqlconnection connection)      {        sqlparameter param = null;        sqlcommand command = new sqlcommand();        int recordsaffected = -1;        connection.open();        command.connection = connection;        command.commandtext = "insert [albums] ([artistid], [albumtitle], [recordinglabel], [format], [hdcd], [soundtrack], [numberofdiscs], [additionalinfo], [releasedate], [albumlength], [incollection], [wishlist], [mediumcover], [largecover]) values (@albumid, @albumtitle, @recordinglabel, @format, @hdcd, @soundtrack, @numberofdiscs, @additionalinfo, @releasedate, @albumlength, @incollection, @wishlist, @mediumcover, @largecover);";          try        {            param = new sqlparameter("@artistid", sqldbtype.nchar, 10);          param.value = null;          command.parameters.add(param);            param = new sqlparameter("@albumtitle", sqldbtype.varchar, 70);          param.value = txtalbum.text.trim();          command.parameters.add(param);            param = new sqlparameter("@recordinglabel", sqldbtype.varchar, 60);          param.value = null; //where read recordinglabel value??          command.parameters.add(param);            param = new sqlparameter("@format", sqldbtype.char, 10);          param.value = formattextbox.text.trim();          command.parameters.add(param);            param = new sqlparameter("@hdcd", sqldbtype.varchar, 4);          param.value = null; //where read recordinglabel value??          command.parameters.add(param);            param = new sqlparameter("@soundtrack", sqldbtype.varchar, 10);          param.value = null; //where read recordinglabel value??          command.parameters.add(param);            param = new sqlparameter("@numberofdiscs", sqldbtype.char, 2);          param.value = txtnumberofdiscs.text.trim();          command.parameters.add(param);            param = new sqlparameter("@additionalinfo", sqldbtype.varchar, 80);          param.value = cbomalbuminfo.text.trim();          command.parameters.add(param);            param = new sqlparameter("@releasedate", sqldbtype.datetime);          param.value = txtreleasedate.text.trim();          command.parameters.add(param);            param = new sqlparameter("@albumlength", sqldbtype.datetime);          param.value = txttracklength.text.trim();          command.parameters.add(param);            param = new sqlparameter("@incollection", sqldbtype.bit);          param.value = null; //where read incollection value??          command.parameters.add(param);            param = new sqlparameter("@wishlist", sqldbtype.bit);          param.value = null; //where read wishlist value??          command.parameters.add(param);            param = new sqlparameter("@mediumcover", sqldbtype.image);          param.value = null; //where read mediumcover value??          command.parameters.add(param);            param = new sqlparameter("@largecover", sqldbtype.image);          param.value = null; //where read largecover value??          command.parameters.add(param);                    recordsaffected = command.executenonquery();          connection.close();          ////2          //paramsalbumcounter++;          //paramsalbum[paramsalbumcounter] = new system.data.sqlclient.sqlparameter("@aritsid", sqldbtype.nchar, 10);          //paramsalbum[paramsalbumcounter].value = txtalbum.text.trim();            ////12          //paramsalbumcounter++;          //paramsalbum[paramsalbumcounter] = new system.data.sqlclient.sqlparameter("@collectionstatus", sqldbtype.varchar, 12);          //paramsalbum[paramsalbumcounter].value = txtalbum.text.trim();            ////13          //paramsalbumcounter++;          //paramsalbum[paramsalbumcounter] = new system.data.sqlclient.sqlparameter("@morealbuminfo", sqldbtype.varchar, 15);          //paramsalbum[paramsalbumcounter].value = txtalbum.text.trim();          }        catch (exception ex)        {          messagebox.show("error occured while executing transaction. transaction unsuccessful", "error", messageboxbuttons.ok);          messagebox.show(ex.message, "actual error", messageboxbuttons.ok);        }        return recordsaffected;      }  


pcrider

well problem in insert statement

 insert into [albums] ([artistid], [albumtitle], [recordinglabel], [format], [hdcd], [soundtrack], [numberofdiscs], [additionalinfo], [releasedate], [albumlength], [incollection], [wishlist], [mediumcover], [largecover])      values (@albumid, @albumtitle, @recordinglabel, @format, @hdcd, @soundtrack, @numberofdiscs, @additionalinfo, @releasedate, @albumlength, @incollection, @wishlist, @mediumcover, @largecover);      

 

based on insert statement should passing artistid instead passing ***@albumid***

also, in parameter list passing @artistid so

@albumid not being passed stored procedure input parameter (instead being passed @artistid..) error message make sense 

******does @albumid need renamed @artistid????***



SQL Server  >  SQL Server Express



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607