返回System.Data.SqlClient.SqlDataReader
库类文件publicSqlDataReaderselectread(stringsql){stringconnectionString=GetConnectionStri...
库类文件
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());
}
哪里错拉呢
标题就是他返回的string 展开
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());
}
哪里错拉呢
标题就是他返回的string 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询