C# Error: Error converting nvarchar datatype to int. HELP! -


i'm having hard time c# application. everytime run code below, gives me error convertion of nvarchar datatype int. have tried casting doesn't seem work.

connectionstring myconnstring = new connectionstring(); string connstring = myconnstring.getconnectionstring(); sqlconnection connvalidate = new sqlconnection(connstring);  sqlcommand cmdvalidate = new sqlcommand("xxx", connvalidate); cmdvalidate.commandtype = commandtype.storedprocedure;  cmdvalidate.parameters.add(new sqlparameter("@accountid", currentuser)); cmdvalidate.parameters.add(new sqlparameter("@periodmonth", convert.tostring(comboboxmonth.selecteditem).trim().toupper())); cmdvalidate.parameters.add(new sqlparameter("@periodyear", convert.toint32(comboboxyear.selectedvalue)));  connvalidate.open();  int32 result = convert.toint32(cmdvalidate.executescalar());  connvalidate.dispose(); connvalidate.close(); 

here stored procedure using:

alter procedure [dbo].[xxx]     @accountid char(6),     @periodmonth char(10),     @periodyear int,     @date int,     @periodid int,     @inventoryid int,     @productoutid int     select @periodid = periodid periods     periodmonth = @periodmonth , periodyear = @periodyear , accountid = @accountid      select @inventoryid = inventoryid fact      periodid = @periodid , accountid = @accountid      select @productoutid = productoutid inventory     inventoryid = @inventoryid      select dailyoutid dailyout     productoutid = @productoutid , date = @date return 

what want here check whether period of same month , year entered user existing in database. basically, stored procedure should return value if period entered exists, if so, messagebox shown user alerting existence of same period. thank much! :)

  1. start sql profiler can capture exact sql being sent server.
  2. copy , paste sql query analyzer or sql management studio.
  3. run it, perferably in debug mode, , tell line number has problem.

my guess periods.periodmonth isn't char(10), need see line error on.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -