无法“System.Data.SqlClient.SqlDataReader”隐式转换为“System.Data.SqlClient.SqlDataAdapter”
出错代码:publicstaticSqlDataAdapterGetReader(stringsql){SqlDataReaderdr=null;SqlConnectio...
出错代码:
public static SqlDataAdapter GetReader(string sql)
{
SqlDataReader dr = null;
SqlConnection conn = new SqlConnection(GetConnStr());
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
try
{
dr=cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
catch
{
conn.Close();
}
return dr;
}
编译器错误消息: CS0029: 无法将类型“System.Data.SqlClient.SqlDataReader”隐式转换为“System.Data.SqlClient.SqlDataAdapter“ 展开
public static SqlDataAdapter GetReader(string sql)
{
SqlDataReader dr = null;
SqlConnection conn = new SqlConnection(GetConnStr());
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
try
{
dr=cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
catch
{
conn.Close();
}
return dr;
}
编译器错误消息: CS0029: 无法将类型“System.Data.SqlClient.SqlDataReader”隐式转换为“System.Data.SqlClient.SqlDataAdapter“ 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询