Problem with parameters

  • Thread starter Thread starter Giorgio Gentilil
  • Start date Start date
G

Giorgio Gentilil

Hello, i'm having a very strange problem,

while every person in this planet could make a parameters procedure from an
access database works ......... guess, i'm not.

The code lines are the next....

con.Parameters.Add("NumLocal", OleDb.OleDbType.SmallInt).Value =
Application("Local") // Is the short way but the long way also fails
con.Parameters.Add("FechaDocs", OleDb.OleDbType.DBTimeStamp).Value = Fecha
// Is the short way but the long way also fails
con.CommandText = "Execute ContarVentas"
DB.open()
NumFilas = con.ExecuteScalar
DB.close()
And the SQL Query is....

PARAMETERS NumLocal Short, FechaDocs DateTime;
SELECT Count(*) AS Expr1
FROM Venta
WHERE (((Venta.Local)=NumLocal) AND ((Venta.Fecha)=FechaDocs));

And the Error is....

Message "El parámetro NumLocal no tiene un valor predeterminado." String
(Literal Translation is: The parameter NumLocal don't have a default value
// Error Code In English is: Too few Parameters)
Source "Microsoft JET Database Engine" String
ErrorCode -2147217904 Integer
StackTrace " at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteScalar()
at fstgo.Import.MoverRegistros() in
c:\inetpub\wwwroot\fstgo\Import.aspx.vb:line 131
at fstgo.Import.CargarDB() in c:\inetpub\wwwroot\fstgo\Import.aspx.vb:line
89
at fstgo.Import.cmdSend_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\fstgo\Import.aspx.vb:line 71" String


What is Wrong?????
 
If this is a stored rpocedure, you need to set the CommandType property to
CommandType.StoredProcedure, and also set the commandtext to contain just
the name of your stored procedure.

Or else, you have to set commandtext to " Execute ContarVentas @NumLocal,
@FechDocs". And I think you would have to prefix the '@' when you are
adding the parameters as well (at least this is how it works in sql server).
 
Thanks a lot, but sadly, i've tried both and none of this options works.

Regards,

Giorgio
 
Back
Top