473,394 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Missing operand

Dim authCommand As String = "select count(*) as iRowCount
from coinfo where loginid = @cocode and ((curr_pwd = @pwd and effdate >
getdate()) or (eff_pwd = @pwd and effdate <= getdate()))"
Dim oleCommand As New OleDbCommand(authCommand,
authConnection)

oleCommand.Parameters.Add(New OleDbParameter("@cocode",
OleDbType.VarChar, 10))
oleCommand.Parameters("@cocode").Value = UserName
oleCommand.Parameters.Add(New OleDbParameter("@pwd",
OleDbType.VarChar, 50))
oleCommand.Parameters("@pwd").Value = UserPassword

Dim iCount As Integer = CType(oleCommand.ExecuteScalar(),
Integer) <--- error
It said "Missing operand" . Please help
Aug 27 '06 #1
10 2306
Well, you shouldn't need to CType the ExcecuteScalar function call because
ExcecuteScalar returns an integer anyway. But, if your command being
executed causes an exception, ExcecuteScalar may be the root of that.

Put your code in a Try...Catch and see if (and by stepping the code) and
where an exception is occuring.
"Agnes" <ag***@dynamictech.com.hkwrote in message
news:ed****************@TK2MSFTNGP03.phx.gbl...
Dim authCommand As String = "select count(*) as iRowCount
from coinfo where loginid = @cocode and ((curr_pwd = @pwd and effdate >
getdate()) or (eff_pwd = @pwd and effdate <= getdate()))"
Dim oleCommand As New OleDbCommand(authCommand,
authConnection)

oleCommand.Parameters.Add(New OleDbParameter("@cocode",
OleDbType.VarChar, 10))
oleCommand.Parameters("@cocode").Value = UserName
oleCommand.Parameters.Add(New OleDbParameter("@pwd",
OleDbType.VarChar, 50))
oleCommand.Parameters("@pwd").Value = UserPassword

Dim iCount As Integer = CType(oleCommand.ExecuteScalar(),
Integer) <--- error
It said "Missing operand" . Please help


Aug 27 '06 #2
Agnes,

The OleDBcommand does AFAIK not use named parameters, therefore are it 3
paremeters, you are offering however only 2. Change the names as @Code just
for ?, than you will see it mabye better.

The documentation about this is not always well on MSDN, it is changed, but
the old ones are not deleted.

Cor

"Agnes" <ag***@dynamictech.com.hkschreef in bericht
news:ed****************@TK2MSFTNGP03.phx.gbl...
Dim authCommand As String = "select count(*) as iRowCount
from coinfo where loginid = @cocode and ((curr_pwd = @pwd and effdate >
getdate()) or (eff_pwd = @pwd and effdate <= getdate()))"
Dim oleCommand As New OleDbCommand(authCommand,
authConnection)

oleCommand.Parameters.Add(New OleDbParameter("@cocode",
OleDbType.VarChar, 10))
oleCommand.Parameters("@cocode").Value = UserName
oleCommand.Parameters.Add(New OleDbParameter("@pwd",
OleDbType.VarChar, 50))
oleCommand.Parameters("@pwd").Value = UserPassword

Dim iCount As Integer = CType(oleCommand.ExecuteScalar(),
Integer) <--- error
It said "Missing operand" . Please help


Aug 27 '06 #3
Yes Cor, oleDBCommand *can* work with named parameters, but the names must
be in the same order as the parameters are in the parameters collection of
the command itself.
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Agnes,

The OleDBcommand does AFAIK not use named parameters, therefore are it 3
paremeters, you are offering however only 2. Change the names as @Code
just for ?, than you will see it mabye better.

The documentation about this is not always well on MSDN, it is changed,
but the old ones are not deleted.

Cor

"Agnes" <ag***@dynamictech.com.hkschreef in bericht
news:ed****************@TK2MSFTNGP03.phx.gbl...
> Dim authCommand As String = "select count(*) as iRowCount
from coinfo where loginid = @cocode and ((curr_pwd = @pwd and effdate >
getdate()) or (eff_pwd = @pwd and effdate <= getdate()))"
Dim oleCommand As New OleDbCommand(authCommand,
authConnection)

oleCommand.Parameters.Add(New OleDbParameter("@cocode",
OleDbType.VarChar, 10))
oleCommand.Parameters("@cocode").Value = UserName
oleCommand.Parameters.Add(New OleDbParameter("@pwd",
OleDbType.VarChar, 50))
oleCommand.Parameters("@pwd").Value = UserPassword

Dim iCount As Integer = CType(oleCommand.ExecuteScalar(),
Integer) <--- error
It said "Missing operand" . Please help



Aug 27 '06 #4
Scott,

I know that you can use them, but in OleDB you can set everything you want
in that place, even a question mark. In the parameters you can than set a
simple "" or whatever you want.

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:Oy**************@TK2MSFTNGP03.phx.gbl...
Yes Cor, oleDBCommand *can* work with named parameters, but the names must
be in the same order as the parameters are in the parameters collection of
the command itself.
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Agnes,

The OleDBcommand does AFAIK not use named parameters, therefore are it 3
paremeters, you are offering however only 2. Change the names as @Code
just for ?, than you will see it mabye better.

The documentation about this is not always well on MSDN, it is changed,
but the old ones are not deleted.

Cor

"Agnes" <ag***@dynamictech.com.hkschreef in bericht
news:ed****************@TK2MSFTNGP03.phx.gbl...
>> Dim authCommand As String = "select count(*) as iRowCount
from coinfo where loginid = @cocode and ((curr_pwd = @pwd and effdate >
getdate()) or (eff_pwd = @pwd and effdate <= getdate()))"
Dim oleCommand As New OleDbCommand(authCommand,
authConnection)

oleCommand.Parameters.Add(New OleDbParameter("@cocode",
OleDbType.VarChar, 10))
oleCommand.Parameters("@cocode").Value = UserName
oleCommand.Parameters.Add(New OleDbParameter("@pwd",
OleDbType.VarChar, 50))
oleCommand.Parameters("@pwd").Value = UserPassword

Dim iCount As Integer = CType(oleCommand.ExecuteScalar(),
Integer) <--- error
It said "Missing operand" . Please help




Aug 27 '06 #5
You can create a parameter and set all of its properties (OleDbType, Name,
Length, Precision, etc.) and all of these will be enforced come
ExecuteCommand time. The actual name @something referenced in the
CommandText is ignored though. Only the amount and order of the parameters
are what is used.
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Scott,

I know that you can use them, but in OleDB you can set everything you want
in that place, even a question mark. In the parameters you can than set a
simple "" or whatever you want.

Cor

"Scott M." <s-***@nospam.nospamschreef in bericht
news:Oy**************@TK2MSFTNGP03.phx.gbl...
>Yes Cor, oleDBCommand *can* work with named parameters, but the names
must be in the same order as the parameters are in the parameters
collection of the command itself.
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>Agnes,

The OleDBcommand does AFAIK not use named parameters, therefore are it 3
paremeters, you are offering however only 2. Change the names as @Code
just for ?, than you will see it mabye better.

The documentation about this is not always well on MSDN, it is changed,
but the old ones are not deleted.

Cor

"Agnes" <ag***@dynamictech.com.hkschreef in bericht
news:ed****************@TK2MSFTNGP03.phx.gbl.. .
Dim authCommand As String = "select count(*) as
iRowCount from coinfo where loginid = @cocode and ((curr_pwd = @pwd and
effdate getdate()) or (eff_pwd = @pwd and effdate <= getdate()))"
Dim oleCommand As New OleDbCommand(authCommand,
authConnection)

oleCommand.Parameters.Add(New OleDbParameter("@cocode",
OleDbType.VarChar, 10))
oleCommand.Parameters("@cocode").Value = UserName
oleCommand.Parameters.Add(New OleDbParameter("@pwd",
OleDbType.VarChar, 50))
oleCommand.Parameters("@pwd").Value = UserPassword

Dim iCount As Integer =
CType(oleCommand.ExecuteScalar(), Integer) <--- error
It said "Missing operand" . Please help




Aug 27 '06 #6
Cor Ligthert [MVP] wrote:
Agnes,

The OleDBcommand does AFAIK not use named parameters, therefore are it 3
paremeters, you are offering however only 2.
<snip>

And then Scott M. argued:
Yes Cor, oleDBCommand *can* work with named parameters, but the names must
be in the same order as the parameters are in the parameters collection of
the command itself.
So if I understand you both correctly, the solution to the OP's problem
would be in the lines of:

<code>
Dim authCommand As String = "select count(*) as iRowCount " _
& "from coinfo where loginid = @p1 " _
& "and ((curr_pwd = @p2 and effdate getdate()) " _
& "or (eff_pwd = @p3 and effdate <= getdate()))"

Dim oleCommand As New OleDbCommand(authCommand, authConnection)

oleCommand.Parameters.Add(New OleDbParameter("@p1", _
OleDbType.VarChar, 10)).Value = UserName

oleCommand.Parameters.Add(New OleDbParameter("@p2", _
OleDbType.VarChar, 50)).Value = UserPassword

oleCommand.Parameters.Add(New OleDbParameter("@p3", _
OleDbType.VarChar, 50)).Value = UserPassword

Dim iCount As Integer = oleCommand.ExecuteScalar()
</code>

Is this right?

Regards,

Branco.

Aug 27 '06 #7
I don't know. I was just letting Cor know about the use of the
OleDbParameters. I still think that the problem would be more traceable if
the code were in a try catch that contained a catch for an OleDbException as
well as an Exception.
"Branco Medeiros" <br*************@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
Cor Ligthert [MVP] wrote:
>Agnes,

The OleDBcommand does AFAIK not use named parameters, therefore are it 3
paremeters, you are offering however only 2.
<snip>

And then Scott M. argued:
>Yes Cor, oleDBCommand *can* work with named parameters, but the names
must
be in the same order as the parameters are in the parameters collection
of
the command itself.

So if I understand you both correctly, the solution to the OP's problem
would be in the lines of:

<code>
Dim authCommand As String = "select count(*) as iRowCount " _
& "from coinfo where loginid = @p1 " _
& "and ((curr_pwd = @p2 and effdate getdate()) " _
& "or (eff_pwd = @p3 and effdate <= getdate()))"

Dim oleCommand As New OleDbCommand(authCommand, authConnection)

oleCommand.Parameters.Add(New OleDbParameter("@p1", _
OleDbType.VarChar, 10)).Value = UserName

oleCommand.Parameters.Add(New OleDbParameter("@p2", _
OleDbType.VarChar, 50)).Value = UserPassword

oleCommand.Parameters.Add(New OleDbParameter("@p3", _
OleDbType.VarChar, 50)).Value = UserPassword

Dim iCount As Integer = oleCommand.ExecuteScalar()
</code>

Is this right?

Regards,

Branco.

Aug 28 '06 #8
Branco,

I have not really checked it complete, but in principle. Yes.

Cor

"Branco Medeiros" <br*************@gmail.comschreef in bericht
news:11**********************@74g2000cwt.googlegro ups.com...
Cor Ligthert [MVP] wrote:
>Agnes,

The OleDBcommand does AFAIK not use named parameters, therefore are it 3
paremeters, you are offering however only 2.
<snip>

And then Scott M. argued:
>Yes Cor, oleDBCommand *can* work with named parameters, but the names
must
be in the same order as the parameters are in the parameters collection
of
the command itself.

So if I understand you both correctly, the solution to the OP's problem
would be in the lines of:

<code>
Dim authCommand As String = "select count(*) as iRowCount " _
& "from coinfo where loginid = @p1 " _
& "and ((curr_pwd = @p2 and effdate getdate()) " _
& "or (eff_pwd = @p3 and effdate <= getdate()))"

Dim oleCommand As New OleDbCommand(authCommand, authConnection)

oleCommand.Parameters.Add(New OleDbParameter("@p1", _
OleDbType.VarChar, 10)).Value = UserName

oleCommand.Parameters.Add(New OleDbParameter("@p2", _
OleDbType.VarChar, 50)).Value = UserPassword

oleCommand.Parameters.Add(New OleDbParameter("@p3", _
OleDbType.VarChar, 50)).Value = UserPassword

Dim iCount As Integer = oleCommand.ExecuteScalar()
</code>

Is this right?

Regards,

Branco.

Aug 28 '06 #9
Hello Scott M.,

Just a quick point.. .ExecuteScalar returns an Object, not an Integer. .ExecuteNonQuery
returns an Integer.

-Boo
Well, you shouldn't need to CType the ExcecuteScalar function call
because ExcecuteScalar returns an integer anyway. But, if your command
being executed causes an exception, ExcecuteScalar may be the root of
that.

Put your code in a Try...Catch and see if (and by stepping the code)
and where an exception is occuring.

"Agnes" <ag***@dynamictech.com.hkwrote in message
news:ed****************@TK2MSFTNGP03.phx.gbl...
>Dim authCommand As String = "select count(*) as iRowCount
from coinfo where loginid = @cocode and ((curr_pwd = @pwd and effdate
>
getdate()) or (eff_pwd = @pwd and effdate <= getdate()))"
Dim oleCommand As New OleDbCommand(authCommand,
authConnection)
oleCommand.Parameters.Add(New OleDbParameter("@cocode",
OleDbType.VarChar, 10)) oleCommand.Parameters("@cocode").Value =
UserName oleCommand.Parameters.Add(New OleDbParameter("@pwd",
OleDbType.VarChar, 50)) oleCommand.Parameters("@pwd").Value =
UserPassword

Dim iCount As Integer = CType(oleCommand.ExecuteScalar(),
Integer) <--- error
It said "Missing operand" . Please help

Aug 28 '06 #10
Oops! My bad, you are right.
"GhostInAK" <gh*******@gmail.comwrote in message
news:be**************************@news.microsoft.c om...
Hello Scott M.,

Just a quick point.. .ExecuteScalar returns an Object, not an Integer.
.ExecuteNonQuery returns an Integer.

-Boo
>Well, you shouldn't need to CType the ExcecuteScalar function call
because ExcecuteScalar returns an integer anyway. But, if your command
being executed causes an exception, ExcecuteScalar may be the root of
that.

Put your code in a Try...Catch and see if (and by stepping the code)
and where an exception is occuring.

"Agnes" <ag***@dynamictech.com.hkwrote in message
news:ed****************@TK2MSFTNGP03.phx.gbl...
>>Dim authCommand As String = "select count(*) as iRowCount
from coinfo where loginid = @cocode and ((curr_pwd = @pwd and effdate

getdate()) or (eff_pwd = @pwd and effdate <= getdate()))"
Dim oleCommand As New OleDbCommand(authCommand,
authConnection)
oleCommand.Parameters.Add(New OleDbParameter("@cocode",
OleDbType.VarChar, 10)) oleCommand.Parameters("@cocode").Value =
UserName oleCommand.Parameters.Add(New OleDbParameter("@pwd",
OleDbType.VarChar, 50)) oleCommand.Parameters("@pwd").Value =
UserPassword

Dim iCount As Integer = CType(oleCommand.ExecuteScalar(),
Integer) <--- error
It said "Missing operand" . Please help


Aug 28 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

69
by: markarichman | last post by:
Why is Firefox complaining with this error: ------------------------------------------------------------ missing ) after argument list setTimeout('breakOut',5000);...
6
by: BlueTrin | last post by:
Hello I was adapting a C version of SolvOpt in C++ to use it within a virtual class. However I am stuck with the overriding of evaluation and gradiant functions. cStepCurveEvaluator.cpp...
13
by: Fir5tSight | last post by:
Hi All, I have a simple VB code: Sub OutputLine(ByRef Level As String, ByRef InfoString As String) Const gSTDOUT As Integer = -11 Dim hStdOut, BytesWritten As Integer Dim s As String s =...
1
by: Fir5tSight | last post by:
Hi, I am using a DataView to displaying a records from datatable. I have a filter that I define it as follows: "Status = '' || Status <'Scanned'" The problems is that I get an error about...
4
by: Mizipzor | last post by:
I have some troubles with a member variable that seems to be missing in a class. In short, heres what I do; class A is the parent class, B inherits from A and C inherits from B (hope I used the...
11
by: Old Wolf | last post by:
Does the following program require a diagnostic? Which section of the Standard deals with this? (I read the section on function calls and didn't see anything). void f(void); int main(void) {...
19
by: Rajesh S R | last post by:
Consider the following code: int main() { struct name { long a; int b; long c; }s={3,4,5},*p; p=&s;
33
by: Stef Mientki | last post by:
hello, I discovered that boolean evaluation in Python is done "fast" (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler...
9
by: Boltar | last post by:
On 32 bit linux with gcc 4.2 I get unexpected results with this code: main() { int bits = 32; printf("%d\n",(int)1 << (int)32); printf("%d\n",(int)1 << bits); }
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.