本文介绍了为什么oracledatareader会为以下代码rply me error ...?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

!!在ORACLE SQL PLUS中加上以下查询运行中...但是这里不起作用.... PLZ帮助...


私有void bt_resultview_Click(对象发送者,EventArgs e)
{
如果(cb_dept.Text =="CSE")
tb_showdeptonrsltview.Text =计算机科学与工程系";

如果(cb_semester.Text ==第一学期")
tb_onlyshowsemesteronrsltview.Text ="1ST SEMESTER";
连接CN =新的connection();
CN.thisConnection.Open();

//OracleCommand thisCommand = CN.thisConnection.CreateCommand();
试试
{
OracleCommand thisCommand =新的OracleCommand(选择course.course_id,course.course_name,course.course_credit,result.lettergrade,result.gradepoint" +
来自课程,结果,其中" +"result.course_id = course.course_id和course.semester =""+ cb_semester.Text +"'');
thisCommand.Connection = CN.thisConnection;
thisCommand.CommandType = CommandType.Text;

OracleDataReader thisReader = thisCommand.ExecuteReader();
while(thisReader.Read())
{

ListViewItem lsvItem = new ListViewItem();
lsvItem.Text = thisReader ["course.course_id"].ToString();
lsvItem.SubItems.Add(thisReader ["course.course_name"].ToString());
lsvItem.SubItems.Add(thisReader ["course.course_credit"].ToString());
lsvItem.SubItems.Add(thisReader ["result.lettergrade"].ToString());
lsvItem.SubItems.Add(thisReader ["result.gradepoint"].ToString());



list_resultview.Items.Add(lsvItem);
}
}
赶上
{
MessageBox.Show(数据库连接问题");
}


OracleCommand thisCommand1 = CN.thisConnection.CreateCommand();

thisCommand1.CommandText =
"SELECT * FROM配置文件,其中regNo =""+ tb_searchregnoforrsltview.Text +"";

OracleDataReader thisReader1 = thisCommand1.ExecuteReader();
while(thisReader1.Read())
{
//MessageBox.Show("successfull);
tb_showregnoonrsltview.Text = thisReader1 ["regNo"].ToString();
tb_showstdnameonrsltview.Text = thisReader1 ["name"].ToString();
}
//thisCommand.Dispose();

CN.thisConnection.Close();



}

!!IN ORACLE SQL PLUS THE FOLLLOWING QUERY RUN...BUT HERE IT IS NOT WORKING....PLZ HELP...


private void bt_resultview_Click(object sender, EventArgs e)
{
if (cb_dept.Text=="CSE")
tb_showdeptonrsltview.Text = "Dept. of Computer Science & Engineering";

if (cb_semester.Text == "1st semester")
tb_onlyshowsemesteronrsltview.Text = "1ST SEMESTER";
connection CN = new connection();
CN.thisConnection.Open();

//OracleCommand thisCommand = CN.thisConnection.CreateCommand();
try
{
OracleCommand thisCommand = new OracleCommand("select course.course_id,course.course_name,course.course_credit,result.lettergrade,result.gradepoint" +
"from course,result where" + "result.course_id=course.course_id and course.semester = ''" + cb_semester.Text + "''");
thisCommand.Connection = CN.thisConnection;
thisCommand.CommandType = CommandType.Text;

OracleDataReader thisReader = thisCommand.ExecuteReader();
while (thisReader.Read())
{

ListViewItem lsvItem = new ListViewItem();
lsvItem.Text = thisReader["course.course_id"].ToString();
lsvItem.SubItems.Add(thisReader["course.course_name"].ToString());
lsvItem.SubItems.Add(thisReader["course.course_credit"].ToString());
lsvItem.SubItems.Add(thisReader["result.lettergrade"].ToString());
lsvItem.SubItems.Add(thisReader["result.gradepoint"].ToString());



list_resultview.Items.Add(lsvItem);
}
}
catch
{
MessageBox.Show("connection problem with database");
}


OracleCommand thisCommand1 = CN.thisConnection.CreateCommand();

thisCommand1.CommandText =
"SELECT * FROM profile where regNo= ''" + tb_searchregnoforrsltview.Text + "''";

OracleDataReader thisReader1 = thisCommand1.ExecuteReader();
while (thisReader1.Read())
{
//MessageBox.Show("successfull");
tb_showregnoonrsltview.Text = thisReader1["regNo"].ToString();
tb_showstdnameonrsltview.Text = thisReader1["name"].ToString();
}
//thisCommand.Dispose();

CN.thisConnection.Close();



}

推荐答案

OracleCommand thisCommand = new OracleCommand("select course.course_id,course.course_name,course.course_credit,result.lettergrade,result.gradepoint" +
         "from course,result where" + "result.course_id=course.course_id and course.semester = ''" + cb_semester.Text + "''");


应该是;


it should be;

OracleCommand thisCommand = new OracleCommand("select course.course_id,course.course_name,course.course_credit,result.lettergrade,result.gradepoint " +
         "from course,result where " + "result.course_id=course.course_id and course.semester = ''" + cb_semester.Text + "''");


请注意第一行末尾和WHERE关键字后的多余空格.


notice the extra spaces at the end of the first line and and after the WHERE key word.


这篇关于为什么oracledatareader会为以下代码rply me error ...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 01:08