Hey Everyone,
I'm trying to write some code using pure SQL using ASP.NET MVC.
I assume I should be building a model, and sticking to the MVC pattern.
Any suggestions for good practice would be highly appreciated, and examples very useful too. For example I'm not sure if I should be splitting this code off from my main repository's, and if I should, where should I put it?
Also I will be attempting to return data from 2 tables in this query.
The kind of query I would like to use is like this.
See top answer from this page
http://stackoverflow.com/questions/852994/how-to-implement-high-performance-tree-view-in-mssql-2005
Also
string sqlGetQuestionAnswers = "SELECT TOP (10) * FROM tblquestion ORDER BY NEWID()";//
using (SqlDataAdapter dapQuestions = new SqlDataAdapter(sqlGetQuestionAnswers, ConfigurationManager.ConnectionStrings["SiteConnectionString"].ToString()))
{
DataSet dsQuestions = new DataSet();
dapQuestions.Fill(dsQuestions);
if (dsQuestions.Tables[0].Rows.Count > 0)
{
work with data;
}
else
{
Error;
}
}