c#连接oracle数据库查询结果返回到winform中的textbox中报错

.Net技术 码拜 8年前 (2016-05-16) 1531次浏览
c#连接oracle数据库查询结果返回到winform中的textbox中能否编译总是报错:在这里OracleDataReader rdr = cmd.ExecuteReader();   报 ORA-00911: 无效字符
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OracleClient;
namespace Oracle
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{

}
private void button1_Click(object sender, EventArgs e)
{
OracleConnection con = new OracleConnection(“Data Source=hdt01;User ID=product;password=product;”);
con.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandText = “select  max(product_item_id) as id  from UP_PRODUCT_ITEM1 where product_item_id like “11100000%”;”;
cmd.CommandType = CommandType.Text;
OracleDataReader rdr = cmd.ExecuteReader();
if (rdr.HasRows)
{
while (rdr.Read())
{
textBox1.Text = rdr.ToString().Trim();
//   textbox1.Text = rdr[“id”].Tostring();
}
}
rdr.Close();

}
}
}

解决方案

20

是不是原因是这里面多了一个分号

cmd.CommandText = "select  max(product_item_id) as id  from UP_PRODUCT_ITEM1 where product_item_id like "11100000%";";

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明c#连接oracle数据库查询结果返回到winform中的textbox中报错
喜欢 (0)
[1034331897@qq.com]
分享 (0)