c# - Cannot find stored procedure -
i have many stored procedure calls in c# code, 1 keeps failing. i'm running vs 2012 , sql server 2008 r2. connection string same stored procedures , have same permissions on of them.
i error
could not find stored procedure 'stp_map_preload @bldg, @linepos, @startd, @lineno, @pgrm, @appos, @sessionid'.
system.exception {system.data.sqlclient.sqlexception}
on line:
sqldatareader dr = cmd.executereader();:
i have tried creating new stored procedure same code, setting permissions, fails too.
public arraylist detailpreload(string bldg, string linepos, datetime startd, string lineno, string pgrm, int appos, string sessionid) { string strsql = "stp_map_preload @bldg, @linepos, @startd, @lineno, @pgrm, @appos, @sessionid"; arraylist list = new arraylist(); using (sqlconnection constr = new sqlconnection(connm)) { using (sqlcommand cmd = new sqlcommand()) { cmd.commandtype = commandtype.storedprocedure; cmd.parameters.clear(); cmd.parameters.addwithvalue("@bldg", bldg); cmd.parameters.addwithvalue("@linepos", linepos); cmd.parameters.addwithvalue("@startd", startd); cmd.parameters.addwithvalue("@lineno", lineno); cmd.parameters.addwithvalue("@pgrm", pgrm); cmd.parameters.addwithvalue("@appos", appos); cmd.parameters.addwithvalue("@sessionid", sessionid); cmd.commandtext = strsql; cmd.connection = constr; constr.open(); sqldatareader dr = cmd.executereader(); while (dr.read()) { list.add(new { company = dr["company"], pgrm = dr["pgrm"], linenum = dr["linenum"], linestation = dr["linestation"], jobcount = dr["job"], item = dr["item"], qty = dr["qty"], partqty = dr["partqty"], invcnt = dr["invcnt"], runid = dr["runid"] }); } constr.close(); return list; } } }
my stored procedure in sql server , can execute in sql server
/* stp_map_preload 'aa-12', '7', '09/19/2014', '', '247', 7, 'val2gxfh5ihoqy4tshzl4tp3' */ alter proc [dbo].[stp_map_preload] @bldg varchar(10), @linepos varchar(5), @startd date, @lineno varchar(5), @pgrm varchar(5), @appos int, @sessionid varchar(50) begin declare @sql varchar(max), @pst varchar(20), @si1 varchar(5), @si2 varchar(5), @si3 varchar(5), @hasap bit, @cclen varchar, @co varchar(5), @ccs varchar(25), @lsgrp varchar(max)...
change line to
string strsql = "stp_map_preload";
there no need list parameters in string names stored procedure.
Comments
Post a Comment