Parameters not recognized??????

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

Giorgio Gentilil

Hello, i'm having a very strange problem,

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

The code lines are the next....

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

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

And the Error is....

a.. 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)
b.. Source "Microsoft JET Database Engine" String
c.. ErrorCode -2147217904 Integer
d.. 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,

Try this:
con.CommandText = "ContarVentas"
con.CommandType = CommandType.StoredProcedure

Let us know if you joined every man on this planet :)

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Hello, i'm having a very strange problem,

while every man 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?????
 
Thanks a lot by your time,

First, I continue out of the "normal" human's kind

Sadly i've tried this and doesn't works, also tried with @ and ? in the
paramenters definitions
(like the command builder does), also I noticed there's some problems with
the word "Local"
seems it is reserved, so I change the table definitions.

For now, I have to give up on this problem and fix by making the query in
the code.

but guess what!!!!, I'm having another weird problem (to be honest, is a
problem that i had one
year ago, and now i'm in the same trouble with another project) , this is
getting really annoying
the situation is the following.

I have a table with a text column, with codes like "VENBOL" or "PAGVTA" but
i also have another records
with the same data in lower case (i.e. "venbol" or "pagvta" ) and I need to
change a value in another row if the
text is in lower case, so first i write the following query

SELECT * FROM Ventas WHERE Ventas.TipoMovimiento <>
ucase(Ventas.TipoMovimiento)

and of course didn't work (the function passed ok, is in JET, but the data
filtered is the entire table) , so i invented this one

SELECT * FROM Ventas WHERE Asc(Ventas.TipoMovimiento) as Expr1 <>
asc(ucase(Ventas.TipoMovimiento))

this one take the ascii code of the first letter in the field and compares
with the "ucased" ascii code, and guess again.... :-(

so the question Nº2 is the following, is there some wrong in what i'm doing
or is just a bug, and there is another way that works?

thanks a lot, I never recived an answer for a question posted before... i
think i'll start to belive in NNTP again ;-)

Regards,

Giorgio
 
Hi Giorgio,

Giorgio Gentilil said:
Thanks a lot by your time,

First, I continue out of the "normal" human's kind

Sadly i've tried this and doesn't works, also tried with @ and ? in the
paramenters definitions
(like the command builder does), also I noticed there's some problems with
the word "Local"
seems it is reserved, so I change the table definitions.

It should work. If you want you can send me a sample project with mdb file
so I can test it.
For now, I have to give up on this problem and fix by making the query in
the code.

but guess what!!!!, I'm having another weird problem (to be honest, is a
problem that i had one
year ago, and now i'm in the same trouble with another project) , this is
getting really annoying
the situation is the following.

I have a table with a text column, with codes like "VENBOL" or "PAGVTA" but
i also have another records
with the same data in lower case (i.e. "venbol" or "pagvta" ) and I need to
change a value in another row if the
text is in lower case, so first i write the following query

SELECT * FROM Ventas WHERE Ventas.TipoMovimiento <>
ucase(Ventas.TipoMovimiento)

and of course didn't work (the function passed ok, is in JET, but the data
filtered is the entire table) , so i invented this one

SELECT * FROM Ventas WHERE Asc(Ventas.TipoMovimiento) as Expr1 <>
asc(ucase(Ventas.TipoMovimiento))

this one take the ascii code of the first letter in the field and compares
with the "ucased" ascii code, and guess again.... :-(

so the question Nº2 is the following, is there some wrong in what i'm doing
or is just a bug, and there is another way that works?

thanks a lot, I never recived an answer for a question posted before... i
think i'll start to belive in NNTP again ;-)

You should believe in NNTP :)
You should compare case sensitive strings in this mode:
where strcomp(Ventas.TipoMovimiento ,ucase(Ventas.TipoMovimiento), 0) = 0
 
You totally must be hired by NASA ;-)

Your solution works great!!!!! After a year of darkness.......... (and
unfair #·$#%$"·$ on Access ;-))

But I have only a "loser question" Was my SQL code wrong or is some kind of
trouble with Strings comparisions in Access????

About the MDB file and the aspx i'll put in my server at
http://www.giolabs.cl/miha (and will be there about a week).

Thanks a lot!!!!!

Giorgio :-)
 
Back
Top