您好我正在尝试在C#中创建CRUD函数,但我被困在我的第一个是FetchALL,因为到目前为止它并不是所有代码路径都返回一个值.
到目前为止,我的代码
public SqlDataReader FetchAll(string tableName)
{
using (SqlConnection conn = new SqlConnection(_ConnectionString,))
{
string query = "SELECT * FROM " + tableName;
SqlCommand command = new SqlCommand(query, conn);
using (SqlDataReader reader = command.ExecuteReader())
conn.Open();
conn.Close();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我可以给你更多信息,谢谢