Kan ikke finde databasen (bruger Enterprise Library Jan. 2006)
HejJeg forsøger at bruge Enterprise Library Jan. 2006 til min database tilgang. Men det vil ikke fungere..
Jeg får følgende fejl:
System.Data.OleDb.OleDbException: Could not find file 'C:\WINDOWS\system32\xxx.mdb'.
Min kode:
using System;
using System.Data;
using System.Globalization;
using System.Text;
using System.Xml;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.Common;
public partial class sider_forside : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
GetCustomerList();
}
public string GetCustomerList()
{
// DataReader that will hold the returned results
// Create the Database object, using the default database service. The
// default database service is determined through configuration.
Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "Select * from Spillere";
DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);
StringBuilder readerData = new StringBuilder();
// The ExecuteReader call will request the connection to be closed upon
// the closing of the DataReader. The DataReader will be closed
// automatically when it is disposed.
using (IDataReader dataReader = db.ExecuteReader(dbCommand))
{
// Iterate through DataReader and put results to the text box.
// DataReaders cannot be bound to Windows Form controls (e.g. the
// resultsDataGrid), but may be bound to Web Form controls.
while (dataReader.Read())
{
// Get the value of the 'Name' column in the DataReader
readerData.Append(dataReader["Name"]);
readerData.Append(Environment.NewLine);
}
}
return readerData.ToString();
}
}
Hjælp?
