By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,906 Members | 1,771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,906 IT Pros & Developers. It's quick & easy.

cannot implicitly convert to bool

P: n/a
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[i]);
if (p[i].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[i].Direction contains the value InputOutput but I
guess am comparing it wrong. Any suggestions?

nick
Nov 3 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You are mising the seconf =

this: if (p[i].Direction = ParameterDirection.InputOutput)
should be if (p[i].Direction == ParameterDirection.InputOutput)
On Nov 3, 11:43 am, Nick <N...@discussions.microsoft.comwrote:
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[i]);
if (p[i].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[i].Direction contains the value InputOutput but I
guess am comparing it wrong. Any suggestions?

nick
Nov 3 '06 #2

P: n/a
Nick wrote:
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[i]);
if (p[i].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[i].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[i].Direction, then , it will be an run
time error instead of compiler - time error.
Nov 3 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.