大家好,我需要您的帮助,我正在尝试执行查询并将所有检索到的数据放入数据集中,但出现此错误"cannot implicitly convert type 'int' to 'system.data.dataset'"
这是代码:
// this is a small piece of the sql
String Astra_conn = ConfigurationManager.ConnectionStrings["AstraSeverConnection"].ConnectionString;
System.Text.StringBuilder sql = new System.Text.StringBuilder();
sql.Append(" SELECT ROWNUM AS ID, institution, LPAD (a.zone_name, 3, '0') AS campus, ");
sql.Append(" term_name AS term, student_instance_id AS student_id, subject, course, ");
sql.Append(" section_name AS section_num, offering AS title, ");
//Its OracleConnection because it is an Oracle server otherwise, it would be SqlConnection.
DataSet rs = new DataSet();
OracleConnection Astra_db_Conn = new OracleConnection(Astra_conn);
string myquery = sql.ToString();
OracleCommand cmd = new OracleCommand(myquery);
Astra_db_Conn.Open();
try
{
SqlDataAdapter adpt = new SqlDataAdapter();
rs = cmd.ExecuteNonQuery(); // this is where is get the error.
adpt.Fill(rs);
}
catch(Exception e)
{
log.Error("*** ERROR *** IRISExportQueries.loadStudentInfoLearningSites():" + e);
}
我也试过
Astra_db_Conn.Open();
try
{
SqlDataReader reader = new SqlDataAdapter();
reader = cmd.ExecuteNonQuery(); // this is where is get the error.
}
catch(Exception e)
{
log.Error(&quot;*** ERROR *** IRISExportQueries.loadStudentInfoLearningSites():&quot; + e);</pre>
}
然后我得到错误:"cannot implicitly convert type 'int' to 'System.Data.SqlClient.SqlDataReader'"
感谢您的帮助,我们将不胜感激。