Problem with Parameters in Access

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?????
 
C

Cor

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top