Monday, September 06, 2010

Stored Procedures and Webmatrix

OK, there isn't a whole lot of documentation for using stored procedures with Microsoft.Data in WebMatrix. Here is one way I got one to work, I'm hoping there is a better way.

Example of a post back insert using a stored proc. Note I'm not doing any validation here, and if you use this method do a little research on SQL Injection and guard against it.

@if (IsPost) {

var LinkName = Request["LinkName"];
var LinkURL = Request["LinkURL"];

string sQ = String.Format("execute dbo.myprocname @LinkName=\"{0}\",
@LinkURL=\"{1}",LinkName, LinkURL);


No comments: