OracleDataReader reader vs Dataset

Guys,
just trying to search for data and show the results in the datagrid

this is what i have done, not quite sure wats going on.

when I do a search for records which i know exists, the datagrid would not be filled


private void btnGo_Click(object sender, System.EventArgs e)
            {
                  string connectionString = "server=TTTD.WORLD;User ID=ttt_currency_conversion;Password=ttt_currency_conversion";
                  OracleConnection con = new  OracleConnection(connectionString);
                  string ora =
                        " SELECT GBP_EXCHANGE_PID, ISO_CODE, DATE_STAMP,  EXCHANGE_RATE " +
                        "  FROM GBP_CURRENCY_RATES  " +
                        "  WHERE ISO_CODE LIKE'"  + this.txtFind.Text +"%' ";
                  OracleCommand cmd = new OracleCommand(ora, con);
                  //     cmd.Parameters.Add(":ISO_CODE",txtFind.Text);
         
                  con.Open();
                  OracleDataReader reader = cmd.ExecuteReader();
                  DgExchange.DataSource = reader;
                  DgExchange.DataBind();
                  reader.Close();
                  con.Close();
            }
                
thanks
SirReadAlotAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Do you have PL/SQL developer installed?

Bob
SirReadAlotAuthor Commented:
nope
SirReadAlotAuthor Commented:
am using toad fornt end.
don't know if that answers the question
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

SirReadAlotAuthor Commented:
how do i used a dataset instead
Bob LearnedCommented:
Try this:

               string ora =
                    " SELECT GBP_EXCHANGE_PID, ISO_CODE, DATE_STAMP,  EXCHANGE_RATE " +
                    "  FROM GBP_CURRENCY_RATES  " +
                    "  WHERE ISO_CODE LIKE'"  + this.txtFind.Text +"%' ";

               OracleDataAdapter adapter = new OracleDataAdapter(ora, connectionString);
         
               DataSet ds = new DataSet();

               adapter.Fill(ds, "Rates");

               DgExchange.DataSource = ds;
               DgExchange.DataMember = "Rates";
               DgExchange.DataBind();

Bob

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob LearnedCommented:
You can run test Select queries in TOAD to make sure that you have the query built correctly.

Bob
SirReadAlotAuthor Commented:
tried this, but same errors as before,

wahts "rates"
private void btnGo_Click(object sender, System.EventArgs e)
                        {
                              string connectionString = "server=TTTD.WORLD;User ID=ttt_currency_conversion;Password=ttt_currency_conversion";
                              OracleConnection con = new  OracleConnection(connectionString);
                        string ora =
                  " SELECT GBP_EXCHANGE_PID, ISO_CODE, DATE_STAMP,  EXCHANGE_RATE " +
                  "  FROM GBP_CURRENCY_RATES  " +
                  "  WHERE ISO_CODE LIKE'"  + this.txtFind.Text +"%' ";
               OracleDataAdapter adapter = new OracleDataAdapter(ora, connectionString);
               DataSet ds = new DataSet();
                 adapter.Fill(ds, "Rates");

            DgExchange.DataSource = ds;
            DgExchange.DataMember = "Rates";
            DgExchange.DataBind();

                              con.Close();
                        }
                
Bob LearnedCommented:
What error are you getting?

"Rates" is an arbitrary table name to avoid getting the generic "Table" for the selected table name.

Bob
SirReadAlotAuthor Commented:
okay, i guess the problem is from my side then
SirReadAlotAuthor Commented:
sorry, its not just retriving the searched value. so the data grid is empty
SirReadAlotAuthor Commented:
I HAVE EVEN USED  the orginal table name.

"GBP_CURRENCY_RATES"; but it does not select anything.

does it matter if my datasets, dataviews are created through drag and drop??



private void btnGo_Click(object sender, System.EventArgs e)
                        {
                              string connectionString = "server=TTTD.WORLD;User ID=ttt_currency_conversion;Password=ttt_currency_conversion";
                              OracleConnection con = new  OracleConnection(connectionString);
            
                              string ora =
                  " SELECT GBP_EXCHANGE_PID, ISO_CODE, DATE_STAMP,  EXCHANGE_RATE " +
                  "  FROM GBP_CURRENCY_RATES  " +
                  "  WHERE ISO_CODE LIKE'"  + this.txtFind.Text +"%' ";

                  OracleDataAdapter oraDataAdatper = new OracleDataAdapter(ora, connectionString);
               //OracleDataAdapter adapter = new OracleDataAdapter(ora, connectionString);
             oraDataSet ds = new oraDataSet();
         //      DataSet ds = new DataSet();
                 oraDataAdatper.Fill(ds, "GBP_CURRENCY_RATES");
                                
            DgExchange.DataSource = ds;
            DgExchange.DataMember = "GBP_CURRENCY_RATES";
            DgExchange.DataBind();

                              con.Close();
                        }
                
SirReadAlotAuthor Commented:
the  query string is very correct.
Bob LearnedCommented:
Did you run the resulting query from TOAD to test it?

Bob
SirReadAlotAuthor Commented:
yes i did,am it returned a result set.

thanks.
SirReadAlotAuthor Commented:
sorry mate,

this doesn't actaully return any data

 SELECT GBP_EXCHANGE_PID, ISO_CODE, DATE_STAMP, EXCHANGE_RATE
 FROM GBP_CURRENCY_RATES
 WHERE ISO_CODE LIKE 'X%'

thanks
SirReadAlotAuthor Commented:
tried this on toad
and it worked
 SELECT GBP_EXCHANGE_PID, ISO_CODE, DATE_STAMP, EXCHANGE_RATE
 FROM GBP_CURRENCY_RATES
 WHERE ISO_CODE LIKE '%G%'
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.