C
Code Monkey
Silly question maybe, but I've been doing the following for far too
long now:
public static DataTable myDataTable()
{
string sql = @"SELECT column1, column2, column3, column4
FROM myTable";
using (SqlConnection conn = new SqlConnection(websqlconn))
{
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
}
The above code would normally be using stored procedures, but for a
little bit of added clarity, I've included a simple query.
Now, the silly bit.
Without going through all the code bloat of Visual Studio IDE and
making the sql and getting the xsd, how would I go about translating
the above code into a strongly typed object?
long now:
public static DataTable myDataTable()
{
string sql = @"SELECT column1, column2, column3, column4
FROM myTable";
using (SqlConnection conn = new SqlConnection(websqlconn))
{
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
}
The above code would normally be using stored procedures, but for a
little bit of added clarity, I've included a simple query.
Now, the silly bit.
Without going through all the code bloat of Visual Studio IDE and
making the sql and getting the xsd, how would I go about translating
the above code into a strongly typed object?