.Net developer

Stored Procedures com SubSonic

Como chamar uma Stored Procedure e obter seus dados num DataTable


StoredProcedure sp = DAL.SPs.Cliente_Listar(3);
DataTable dt = sp.GetDataSet().Tables[0];

string nome;
foreach (DataRow row in dt.Rows)
{
nome = row[1].ToString();
}

Para executar uma procedure só de atualização ou insert, bastava dar um sp.Execute() ao invés do GetDataSet().

No código, ao digitar o DAL.SPs. (logo depois do ponto) são listadas pelo Visual Studio todas as procedures da base!.

Para rodar este código, necessário o using SubSonic.

Como ter Subsonic? Se vira: http://www.subsonicproject.com/ ou dá uma googleada!

2 comentários:

Anônimo disse...

Great goods from you, man. I have consider your stuff prior to
and you are just extremely magnificent. I actually like what you have received right here, certainly like what you're stating and the way by which you are saying it. You make it enjoyable and you continue to care for to stay it smart. I cant wait to learn much more from you. This is actually a great web site.

Feel free to surf to my web page :: instagram

Anônimo disse...

Wow, that's what I was seeking for, what a stuff! present here at this web site, thanks admin of this web site.

Stop by my page; twitter retweets free way to get more instagram followers