passing list<> sql stored procedure


i've mostly bucket churned equipment sole record database. example: web page displays equipment consolidate unparalleled report, annals database (report record news table, equipment annals vigilant table). user selecting equipment consolidate unparalleled news around web app, let's contend name 3 equipment submit. slight supplement 3 equipment news adding annals list called reportitems (reportid,itemid).



currently, i something in code:



public vacant additemstoreport(string connstr, int id, list<int> itemlist)
{
database db = databasefactory.createdatabase(connstr);

twine sqlcommand = "additemstoreport"
dbcommand dbcommand = db.getstoredproccommand(sqlcommand);

twine equipment = "";
foreach (int i itemlist)
equipment += string.format("{0}~", i);

(items.length > 0)
equipment = items.substring(0, items.length - 1);

// supplement parameters
db.addinparameter(dbcommand, "reportid", dbtype.int32, id);
db.addinparameter(dbcommand, "items", dbtype.string, perms);
db.executenonquery(dbcommand);
}


and stored procedure:



insert reportitem (reportid,itemid)
select @reportid,
id
from fn_getinttablefromlist(@items,'~')


where duty advantage buttress list integers.



my doubt this: there improved proceed hoop something this? note, i'm seeking database normalizing anything that, doubt relates personally code.



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members