PDS8475
Active member
- Joined
- Jun 25, 2019
- Messages
- 41
- Programming Experience
- Beginner
Hi
I have a C# Form with a DataGridView (Records_dataGridView) that I am trying to fill from the access table "Donations" when the form loads.
I have a dataAdaptor (DA)
which fills a dataTable (DT)
which is the dataSource for Records_dataGridView
which can be seen in the code below
The problem is I get the following exception when I try to load the form
I have a C# Form with a DataGridView (Records_dataGridView) that I am trying to fill from the access table "Donations" when the form loads.
I have a dataAdaptor (DA)
which fills a dataTable (DT)
which is the dataSource for Records_dataGridView
which can be seen in the code below
C#:
private void Reports_Form_Load(object sender, EventArgs e)
{
string ConString = System.IO.File.ReadAllText("FixIT.con");
ConString = ConString.Replace(System.Environment.NewLine, string.Empty);
System.Data.OleDb.OleDbConnection connn = new System.Data.OleDb.OleDbConnection();
string connsString = "Provider = Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + ConString;
try
{
using (OleDbConnection connection = new OleDbConnection(connsString))
{
using (OleDbCommand command = new OleDbCommand("Select * FROM Donations", connection))
{
command.CommandType = CommandType.Text;
using (OleDbDataAdapter DA = new OleDbDataAdapter(command))
{
using (DataTable DT = new DataTable())
{
DA.Fill(DT);
Records_dataGridView.DataSource = DT;
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
It appears that the error happens when the dataAdaptor tries to fill the dataTable but I don't know why.System.Data.OleDb.OleDbException (0x80040E4D): No error message available, result code: DB_SEC_E_AUTH_FAILED(0x80040E4D).
at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at FixIT.Reports_Form.Reports_Form_Load(Object sender, EventArgs e) in C:\Users\Paul\source\repos\FixIT\FixIT\Reports_Form.cs:line 60
Last edited: