Ok so I have made ASP.NET website I have used Access database 2010 but I am having problems with one particular thing when I try and run the website I am getting this error which says OleDbException was unhandled by user code and Could not find file 'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\CitiesDatabase.accdb'. The error points at
myTable = new DataTable();
dataAdapter.Fill(myTable);
Here is my code:
Code blocks are created by indenting at least 4 spaces
... and can span multiple lines
public partial class NavigateDatabase : System.Web.UI.Page
{
DataTable myTable;
OleDbDataAdapter dataAdapter;
int rowIndex;
protected void Page_Load(object sender, EventArgs e)
{
string connStr;
string sqlStr;
connStr = "PROVIDER = Microsoft.jet.OLEDB.4.0;" +
"Data Source = tblCities.mdb";
sqlStr = "SELECT * FROM FootballResults";
dataAdapter = new OleDbDataAdapter(sqlStr, connStr);
myTable = new DataTable();
dataAdapter.Fill(myTable);
}
public void upDateTextBoxes(int row)
{
txtCity.Text =
myTable.Rows[row]["Team"].ToString();
txtCountry.Text =
myTable.Rows[row]["Player"].ToString();
Session.Add("RowIndex", row);
}
protected void button1_Click(object sender,
EventArgs e)
{
rowIndex = 0;
upDateTextBoxes(rowIndex);
}
protected void button2_Click(object sender,
EventArgs e)
{
rowIndex = Convert.ToInt16( Session["RowIndex"]);
if(rowIndex<((myTable.Rows.Count) -1))
{
rowIndex++;
upDateTextBoxes(rowIndex);
}
}
protected void button3_Click(object sender,
EventArgs e)
{
rowIndex = Convert.ToInt16( Session["RowIndex"]);
if (rowIndex > 0)
{
rowIndex--;
upDateTextBoxes(rowIndex);
}
}
protected void button4_Click(object sender,
EventArgs e)
{
rowIndex = myTable.Rows.Count - 1;
upDateTextBoxes(rowIndex);
}
}