Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

I want to fetch multiple data from oracle database and want to store it into another variables in C#

goldie12Aug 14 2013 — edited Nov 12 2013

I want to fetch multiple data from oracle database and want to store it into another variables in C# .net.

Kindly help me on this and suggest me a code.As for now I am using this code:-

Here is my Code.

string conn = "provider=MSDAORA;data source=mdmdb_tb;user id=testapp;password=testapp";

            using (OleDbConnection myOleDbConnection = new OleDbConnection(conn))

            {

                myOleDbConnection.Open();

                using (OleDbCommand cmd = new OleDbCommand("SELECT DISTINCT AC.ACCOUNTID as accid ,MT.SERIALNUMBER as srno,AC.NAME as names,OC.OPCONAME as town1,OC.CITY discm FROM ACCOUNT AC, XXMETERHIST M, LSMDPHYSICALMETER MT,LSSERVICEPOINT P,LSMDMTRMANUFACTURER MANUFAC,OPERATINGCOMPANY OC,LSMARKET LS WHERE AC.UIDACCOUNT = M.UIDACCOUNT AND M.UIDPHYSICALMETER = MT.UIDPHYSICALMETER and LS.MARKETID = OC.OPCOCODE and LS.UIDMARKET = P.UIDMARKET and MANUFAC.UIDMTRMANUFACTURER = MT.UIDMETERMANUFACTURER AND M.UIDSERVICEPOINT = P.UIDSERVICEPOINT and MT.SERIALNUMBER ='?' AND MT.UIDPHYSMTRTYPE = '43' ORDER BY 1", myOleDbConnection))

                {

                    OleDbParameter p1 = new OleDbParameter();

                    p1.ParameterName = "@MeterSerialNumber";

                    p1.OleDbType = OleDbType.VarChar;

                    p1.Direction = ParameterDirection.Input;

                    p1.Value = MeterSerialNumber;

                    cmd.Parameters.Add(p1);

                    using (OleDbDataReader reader = cmd.ExecuteReader())

                    {

                        while (reader.Read())

                        {

                            string accid = (string)reader["accid"];

                            string srno = (string)reader["srno"];

                            string names = (string)reader["names"];

                            string town1 = (string)reader["town1"];

                            string discm = (string)reader["discm"];

                        }

                    }

                }

            }

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 11 2013
Added on Aug 14 2013
0 comments
1,330 views