Daniel Morais

Daniel Morais

  • NA
  • 9
  • 9.6k

c# database Access 2000

Jan 27 2010 5:00 PM

The code is
I have a small probleme with this code
When i click on on a post title that is set in a listbox from de database
it only bring me to the last written post
is there a way in c# to manage this so i can read read the post
that go's with the title clicked.
 

private
void lb_SelectedIndexChanged(object sender, EventArgs e)
{
Myconnection =
new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Password=; Data Source=" + File_Name);
Myconnection.Open();
OleDbCommand cmd = Myconnection.CreateCommand();
cmd.CommandText =
"SELECT * FROM POST";
OleDbDataAdapter dta = new OleDbDataAdapter(cmd.CommandText, Myconnection);
dta =
new OleDbDataAdapter(cmd);
DataSet dts = new DataSet("POST");
dta.Fill(dts,
"POST");
foreach (DataRow row in dts.Tables["POST"].Rows)
{
TitleBox.Text = row[1, DataRowVersion.Current].ToString();
rtf.Rtf = row[2, DataRowVersion.Current].ToString();
}
Myconnection.Close();
lb.Visible =
false;
}
Tank-you

Answers (2)