I am unsure but i am unable to get the data to show in the text box. Here is the code i have written so far. Any help would be great. There is nothing going in the boxes but doing the test i got the message box. Is there something i am not doing correct ? I can provide the access file if needed. But is is just five fields with data in it.
DataSet DataSet1; //use to put data in form
System.Data.OleDb.OleDbDataAdapter dataadapter;
private void Breed_Load(object sender, EventArgs e)
{
dbconnect = new System.Data.OleDb.OleDbConnection();//database connection variable
DataSet1 = new DataSet(); //variable to help get info from DB
dbconnect.ConnectionString = "PROVIDER= Microsoft.Jet.OLEDB.4.0; Data Source=C:/Pets.mdb"; //location of DB to open
dbconnect.Open(); //open command for DB
string sql = "SELECT * From tblPets"; //sql string to select all records from the table pets
dataadapter = new System.Data.OleDb.OleDbDataAdapter(sql, dbconnect); // pulls the records from sql command
MessageBox.Show("Database is Open");
dataadapter.Fill(DataSet1, "Pets"); // used the database to fill in the form.
NavRecords(); //calls NavRecords Method
dbconnect.Close();
MessageBox.Show("Database is Closed");
dbconnect.Dispose();
}
private void NavRecords()
{
DataRow DBrow = DataSet1.Tables["Pets"].Rows[0];
//PetNametextBox.Text = DBrow.ItemArray.GetValue(1).ToString(); //puts data in textbox
TypeofPettextBox.Text = DBrow.ItemArray.GetValue(1).ToString();//puts data in textbox
PetWeighttextBox.Text = DBrow.ItemArray.GetValue(2).ToString();//puts data in textbox
ShotsUpdatedtextBox.Text = DBrow.ItemArray.GetValue(3).ToString();//puts data in textbox
AdoptabletextBox.Text = DBrow.ItemArray.GetValue(4).ToString();//puts data in textbox
BreedtextBox.Text = DBrow.ItemArray.GetValue(5).ToString();//puts data in textbox
}
DBrow[0]/DBrow[1] ...