C
checoz
I'm trying to do a INSERT in a table with this code:
protected int RunProcedure(string storedProcName, IDataParameter[]
parameters, out int rowsAffected){
int result=0;
rowsAffected = 0;
try{
Connection.Open();
OleDbCommand command = BuildIntCommand(storedProcName,parameters);
rowsAffected = command.ExecuteNonQuery();
result = (int)command.Parameters["ReturnValue"].Value;
Connection.Close();
}
catch(OleDbException e){...
}
private OleDbCommand BuildIntCommand(string storedProcName,
IDataParameter[] parameters)
{
OleDbCommand command = BuildQueryCommand(storedProcName,parameters);
command.Parameters.Add(new OleDbParameter("ReturnValue",
OleDbType.Numeric, 4,
ParameterDirection.ReturnValue,
false,
0,
0,
string.Empty,
DataRowVersion.Default,
null));
return command;
}
private OleDbCommand BuildQueryCommand(string storedProcName,
IDataParameter[] parameters)
{
OleDbCommand command = new OleDbCommand(storedProcName, Connection);
command.CommandType = CommandType.StoredProcedure;
foreach(OleDbParameter parameter in parameters)
{
command.Parameters.Add(parameter);
}
return command;
}
My DataBase is Access 2000 and the called store is:
PARAMETERS [@ID_INTERVENTO] Long;
INSERT INTO TABLE_NAME(FIELD1)
VALUES ([@PARAM1]);
On command.ExecuteNonQuery() i have always this error:
"Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done."
Have you got any solutions??
thanks
protected int RunProcedure(string storedProcName, IDataParameter[]
parameters, out int rowsAffected){
int result=0;
rowsAffected = 0;
try{
Connection.Open();
OleDbCommand command = BuildIntCommand(storedProcName,parameters);
rowsAffected = command.ExecuteNonQuery();
result = (int)command.Parameters["ReturnValue"].Value;
Connection.Close();
}
catch(OleDbException e){...
}
private OleDbCommand BuildIntCommand(string storedProcName,
IDataParameter[] parameters)
{
OleDbCommand command = BuildQueryCommand(storedProcName,parameters);
command.Parameters.Add(new OleDbParameter("ReturnValue",
OleDbType.Numeric, 4,
ParameterDirection.ReturnValue,
false,
0,
0,
string.Empty,
DataRowVersion.Default,
null));
return command;
}
private OleDbCommand BuildQueryCommand(string storedProcName,
IDataParameter[] parameters)
{
OleDbCommand command = new OleDbCommand(storedProcName, Connection);
command.CommandType = CommandType.StoredProcedure;
foreach(OleDbParameter parameter in parameters)
{
command.Parameters.Add(parameter);
}
return command;
}
My DataBase is Access 2000 and the called store is:
PARAMETERS [@ID_INTERVENTO] Long;
INSERT INTO TABLE_NAME(FIELD1)
VALUES ([@PARAM1]);
On command.ExecuteNonQuery() i have always this error:
"Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done."
Have you got any solutions??
thanks