Problem with Parameters in Access

  • 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?????
 
Hi Giorgio,

Con is in most from latin derived languages almost the same but not command.
In dotnet languages it mostly the shortcut for connection.
I mis the command declaration.

I think this cannot be true, but I ask it anyway

dim con as new Oledb.Oledbconnection
dim cmd as new Oledb.Oledbcommand

How did you describe this?

Cor
 
Back
Top