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);
}

}

So... my first question is... is this website hosted on a domain somewhere or is it hosted on your local computer?

The reason I ask this is because your connection string seems to be pointing at an access database on a local drive as such:
C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\CitiesDatabase.accdb

So... if it's hosted online one might want to double-check the connection string to ensure it's properly pointing to the .accdb file location. One may also want to make sure that the perms on that file are set correctly in such a way that the code can actually reach the file (i.e.: readable/writable).

It's somewhat difficult to tell as the code you provided doesn't seem to fully encompass the connection string other than to reference a connection type and a .mdb file and doesn't indicate anywhere within where it would be referencing CitiesDatabase.accdb.

My thought is that, if it's not related to the code above... you may have data connections hard coded into the front end of your page in datatables or dropdowns or the likes which are pointing at local files instead of site resources.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.