Connecting to MS Access Database From .NET 2.0
For some reason, I couldn't find a good example
online. Remembered I had done this successfully with PC Sitter Web.
Here's the code that returns an array list:
Code:
Code:
{ string strSQL = "SELECT * FROM Albums"; string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath( System.Configuration.ConfigurationManager.ConnectionStrings ["AccessPhotoGalConnectionString"].ToString()); DataTable dataTable = new DataTable(); OleDbDataAdapter lDbConn = new OleDbDataAdapter(strSQL, ConnectionString); DbConnAdapter = lDbConn; DbConnAdapter.Fill(dataTable); //loop thru database tables foreach (DataRow dr in dataTable.Rows) { arrPhotos.Add(dr.ItemArray); counter++; } } catch (Exception ex) { UIManager.LogError(ex); throw ex; } return arrPhotos; |


Comments