缺少操作数 [英] Missing operand
问题描述
Dim authCommand As String =" select count(*)as iRowCount
来自coinfo,其中loginid = @cocode和((curr_pwd = @pdd和effdate>
getdate())或(eff_pwd = @pwd和effdate< = getdate()))"
Dim oleCommand As New OleDbCommand(authCommand,
authConnection)
oleCommand.Parameters.Add(新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(),
整数)< ---错误
它说缺少操作数 。请帮助
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
推荐答案
好吧,你不需要对ExcecuteScalar函数调用进行CType,因为
ExcecuteScalar返回一个整数无论如何。但是,如果您执行的命令是执行异常,则ExcecuteScalar可能是其中的根。
将您的代码放入Try ... Catch和看看是否(并通过踩代码)和
发生异常。
" Agnes" < ag *** @ dynamictech.com.hkwrote in message
news:ed **************** @ TK2MSFTNGP03.phx.gbl ...
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和effdate>
getdate())或(eff_pwd = @pwd和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作为Integer = CType(oleCommand.Ex ecuteScalar(),
整数)< ---错误
它说缺少操作数 。请帮助
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
Agnes,
OleDBcommand不使用命名的AFAIK参数,因此它是3
参数,你只提供2个。更改名称为@Code只需
for ?,比你会更好地看到mabye。
关于这个的文档在MSDN上并不总是很好,它已被更改,但是
旧的不会被删除。
Cor
" Agnes" < ag *** @ dynamictech.com.hkschreef in bericht
news:ed **************** @ TK2MSFTNGP03.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和effdate>
getdate())或(eff_pwd = @pwd和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作为Integer = CType(oleCommand。 ExecuteScalar(),
整数)< ---错误
它说缺少操作数 。请帮助
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
是Cor,oleDBCommand *可以*使用命名参数,但名称必须
与命令本身的参数集合中的参数顺序相同。
Cor Ligthert [MVP]" < no ************ @ planet.nlwrote in message
news:%2 **************** @ TK2MSFTNGP04.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,
OleDBcommand使AFAIK不使用命名参数,因此它是3
参数,你只提供2个。更改名称为@Code
只是为了?,比你会更好地看到它更好。
关于这个的文档在MSDN上并不总是很好,它已被更改,
但旧的不会被删除。
Cor
" Agnes" < ag *** @ dynamictech.com.hkschreef in bericht
news:ed **************** @ TK2MSFTNGP03.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())或(eff_pwd = @pwd和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() ,
整数)< ---错误
它说缺少操作数 。请帮助
> 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
这篇关于缺少操作数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!