cannot implicitly convert to bool

G

Guest

I am trying to find out if particular array element contains InputOutput
value.

private static int FillParameters(DbCommand command, SqlParameter[] p)
{
int x = 0; //int initalize to hold zero
for (int i = 0; i < p.Length; i++)
{
command.Parameters.Add(p);
if (p.Direction = ParameterDirection.InputOutput) <<<==
error here
x = i;
}
}

but I am getting errors as follows:

Error 39 Cannot implicitly convert type 'System.Data.ParameterDirection' to
'bool' C:\IList_WareHouse_Solution\DataObjects\Db.cs 277 22 DataObjects

all I want to know is if p.Direction contains the value InputOutput but I
guess am comparing it wrong. Any suggestions?

nick
 
B

Bill Rodenbaugh

You are mising the seconf =

this: if (p.Direction = ParameterDirection.InputOutput)
should be if (p.Direction == ParameterDirection.InputOutput)
 
J

Jianwei Sun

Nick said:
I am trying to find out if particular array element contains InputOutput
value.

private static int FillParameters(DbCommand command, SqlParameter[] p)
{
int x = 0; //int initalize to hold zero
for (int i = 0; i < p.Length; i++)
{
command.Parameters.Add(p);
if (p.Direction = ParameterDirection.InputOutput) <<<==
error here
x = i;
}
}

but I am getting errors as follows:

Error 39 Cannot implicitly convert type 'System.Data.ParameterDirection' to
'bool' C:\IList_WareHouse_Solution\DataObjects\Db.cs 277 22 DataObjects

all I want to know is if p.Direction contains the value InputOutput but I
guess am comparing it wrong. Any suggestions?

nick


you should use == instead of =

It's nice that the compiler will give you this error. In C++, it will
silently assign the value to p.Direction, then , it will be an run
time error instead of compiler - time error.
 

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