0
00unknown.user00
Is there any way to determine the cause of an OleDbException? For
instance. for "No value given for one or more required parameters." is
there a way to determine which parameter is missing? Or for the "Data
type mismatch in criteria expression", to determine which parameter is
causing the problem?
I'm ripping my hair out trying to track these things down.
The queries generally work perfectly fine when used directly in Access,
but when executed through my code, they fail.
Here's an example:
private string insertCommandString = @"INSERT INTO AppUser(Id,
Username, Passphrase, Permissions, Creator_Id) VALUES (@Id, @Username,
@Passphrase, @Permissions, @Creator_Id)";
OleDbCommand insertCmd = new OleDbCommand( insertCommandString );
insertCmd.Parameters.Add( "@Id", item.Id );
insertCmd.Parameters.Add( "@Username", item.Username );
insertCmd.Parameters.Add( "@Passphrase", item.Passphrase );
insertCmd.Parameters.Add( "@Permissions", item.Permissions );
insertCmd.Parameters.Add( "@Creator_Id", appuser_Id );
using ( OleDbConnection conn = new OleDbConnection(_connectionString )
)
{
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
}
This generates a "No value given for one or more required parameters."
exception. But when I create a query: "INSERT INTO AppUser(Id,
Username, Passphrase, Permissions, Creator_Id) VALUES (@Id, @Username,
@Passphrase, @Permissions, @Creator_Id)" and execute it via Access, it
asks me for the parameters correctly.
This is driving me insane, I've got 20 different classes and each one
ends up having these problems.
instance. for "No value given for one or more required parameters." is
there a way to determine which parameter is missing? Or for the "Data
type mismatch in criteria expression", to determine which parameter is
causing the problem?
I'm ripping my hair out trying to track these things down.
The queries generally work perfectly fine when used directly in Access,
but when executed through my code, they fail.
Here's an example:
private string insertCommandString = @"INSERT INTO AppUser(Id,
Username, Passphrase, Permissions, Creator_Id) VALUES (@Id, @Username,
@Passphrase, @Permissions, @Creator_Id)";
OleDbCommand insertCmd = new OleDbCommand( insertCommandString );
insertCmd.Parameters.Add( "@Id", item.Id );
insertCmd.Parameters.Add( "@Username", item.Username );
insertCmd.Parameters.Add( "@Passphrase", item.Passphrase );
insertCmd.Parameters.Add( "@Permissions", item.Permissions );
insertCmd.Parameters.Add( "@Creator_Id", appuser_Id );
using ( OleDbConnection conn = new OleDbConnection(_connectionString )
)
{
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
}
This generates a "No value given for one or more required parameters."
exception. But when I create a query: "INSERT INTO AppUser(Id,
Username, Passphrase, Permissions, Creator_Id) VALUES (@Id, @Username,
@Passphrase, @Permissions, @Creator_Id)" and execute it via Access, it
asks me for the parameters correctly.
This is driving me insane, I've got 20 different classes and each one
ends up having these problems.