Hi guys.
I'm making a DAL class which I can use to connect to DB and retrieve data. I'm using SQL Server 2005 Express (and Visual Web Developer 2008 Express Edition).
I found several examples on the web for connecting an retrieving data. But none where made inn to a class object.
This is kind of a pseudocode I've put together. Can anyone help me with some code which I can use to get data from MS DB?
namespace development.DAL {
public class myDAL
{
SqlConnection conn;
string conStr = "myConnectionString";
public myDAL()
{
string connStr = Config.Get(this.conStr);
this.conn = new SqlConnection(connStr);
}
// Function for retrieving data from DB
public DataSet GetAllRows(string table)
{
string sql = string.Format(@"
SELECT *
FROM '{0}';
", table);
DataSet dbDataSet = Command.CreateDataSet(cmd); //Pseudocode!
return dbDataSet;
}
}
}