c# - Connecting to Legacy Stored Procedures and Database -
i wonder if point me in right direction please?
i'm working in vs2013 c# asp.net mvc4 application (my first) , need connect , run stored procedures in existing sql server database.
i know there loads of documentation/articles out there but, honest, i've ended confusing myself.
could point me in right direction please?
thanks, craig
create sql connection:
var connection = new sqlconnection(connectionstring); then create command - 'run stored procedure command':
var command = new sqlcommand("mystoredprocedurename", connection) { commandtype = commandtype.storedprocedure }); open connection
connection.open(); execute procedure:
command.executenonquery(); close connection (you should replace above using statements):
connection.close(); if stored procedure returns data, need use different execute method.
Comments
Post a Comment