I have the following code:
public static DataTable GetDataTable(string sConnStr, string sTable)
{
DataTable dt = new DataTable();
SqlConnection sqlConn10 = new SqlConnection(sConnStr);
sqlConn10.Open();
SqlCommand sqlComm10 = new SqlCommand("SELECT * FROM " + sTable, sqlConn10);
SqlDataReader myReader10 = sqlComm10.ExecuteReader();
try
{
while (myReader10.Read())
{
// Code needed
}
}
catch
{
myReader10.Close();
sqlConn10.Close();
}
return dt;
}
The problem is, I don't know how to go on. All I want is to get a DataTable with the data from the SQL-Statement. Thanks for your help!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…