Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();

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.
Posted
Updated 18-Nov-10 23:01pm
v2
Comments
Kasunmit 19-Nov-10 5:51am    
yep correct it is a printning mistake

Remove the ";" before order by clause in your query
 
Share this answer
 
Hi Kasunmit,

shouldn't the code look more like:

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


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
 
Share this answer
 
Comments
Kasunmit 19-Nov-10 5:51am    
but quary is running with out error in oracle side ...
Manfred Rudolf Bihy 19-Nov-10 6:39am    
Does the DataTable returned by GetSQLData() contain any records? I'd advise you to set a breakpoint at the start of the GetSQLData method and step through the code to see what happens. Maybe an exception occurs and null is returned. What exactly do you mean by "It doesn't work"?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900