将Oracle数据获取到下拉列表 [英] Get oracle data to Drop down list

查看:109
本文介绍了将Oracle数据获取到下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用以下代码来获取oracle表列数据以下拉列表

Hi,

I used following code to get oracle table column data to drop down list

connection.Open();
string qu = "select NAME from dbinfo where status !=DROPED ; order by NAME";
drpSID.DataSource = GetSQLData(qu);
connection.Close();


但这没用. GetSQLData函数如下:


but it dosen''t work. The GetSQLData function is as follows:

public DataTable GetSQLData(string query)
{
  try
  {
    DataTable dt = new DataTable();
    if (connection.State == ConnectionState.Closed)
      connection.Open();
    command.Connection = connection;
    command.CommandType = CommandType.Text;
    command.CommandText = query;
    OracleDataAdapter da = new OracleDataAdapter(command);
    da.Fill(dt);
    return dt;
  }
  catch (Exception)
  {
    return null;
  }
}



我不知道该怎么办.



I don''t know what I have to do.

推荐答案

删除;"在查询中按顺序排序之前
Remove the ";" before order by clause in your query


Kasunmit,

代码不应该更像:

Hi Kasunmit,

shouldn''t the code look more like:

string qu = "select NAME from dbinfo where status <> ''DROPED'' order by NAME";



不等于的关系运算符是<>",这就是我使用它的方式.
并且如果status是一个基于字符的字段,则字符串文字周围的单引号应按顺序排列.

希望对您有帮助

干杯

曼弗雷德(Manfred)



The relational operator for not equal to is "<>", that''s how I''d use it.
And if status is a character bases field single quotes around the string literal are in order.

Hope that helps

Cheers

Manfred


这篇关于将Oracle数据获取到下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆