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

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -