返回System.Data.SqlClient.SqlDataReader
asp吧
全部回复
仅看楼主
level 4
sekeng 楼主
库类文件
public SqlDataReader selectread(string sql)
{
string connectionString = GetConnectionString();
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(sql, connection);
if(connection.State==ConnectionState.Closed)
{
connection.Open();
}
SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
return reader;
}
page_load文件
Class1 sqlq = new Class1();
SqlDataReader reader = sqlq.selectread("select * from user");
while(reader.Read())
{
Response.Write (reader.ToString());
}
谁知道哪里错拉呢~
2015年04月16日 23点04分 1
1