Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Oracle 8 and C#

Status
Not open for further replies.

ukemike

Programmer
Aug 14, 2003
8
US
Hi. im trying to read a bunch of records from an oracle table into a hashtable in C#. Everything looks good except, it should read every record, instead it reads every other record. (1, 3, 5. etc....) I know this code is kinda long but can anyone take a look and see what might be wrong.??

thanx.
here is it:
private void btnLoadRecords_Click(object sender, System.EventArgs e)
{

lblStatus.Text = "Connecting..";
string b = my_reader.open_connection();
if (b=="c")
{
lblStatus.Text = "Connected";
}
else
{
lblStatus.Text = "Not connected";

}

try
{
int counter = 0;
string my_string = "SELECT * FROM customer_information";
OleDbDataReader result = my_reader.write_with_return(my_string);
while(result!= null)
{
string all_together = Convert.ToString(result["CUS_NAME"]) + ":" +
Convert.ToString(result["CUS_ADDRESS"]) + ":" +
Convert.ToString(result["CUS_CITY"]) + ":" +
Convert.ToString(result["CUS_STATE"]) + ":" +
Convert.ToString(result["CUS_PHONE"]) + ":" +
Convert.ToString(result["CUS_ID"]) + ":" +
Convert.ToString(result["CUS_RANK"]);
hash.Add(counter, all_together);
result = my_reader.write_with_return_again();
counter = counter + 1;

}


}
catch (Exception d)
{

MessageBox.Show("Could not load records in", "Error");
}



// lblStatus.ForeColor = Color.Red;
// lblStatus.Text = "Cannot connect";


}

;--------------------- this is my object_reader class---------(only one portion shown)---------------

public OleDbDataReader write_with_return(string text) //return OleDbDataReader object
{
myDBobject.CommandText = text;
myDataReader = myDBobject.ExecuteReader ();
myDataReader.Read();
return myDataReader;


}

public OleDbDataReader write_with_return_again() //read another row
{
myDataReader.Read();
if(myDataReader.Read())
{
return myDataReader;
}
else
{
myDataReader = null;
return myDataReader;

{


}
}



;---- the open_connection method works. the only part of the code that there might be a bug in is this one posted right here. I didnt want to post the whole code cuz it would be too big. thanx guys
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top