473,320 Members | 1,862 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,320 software developers and data experts.

cannot implicitly convert to bool

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
2 3635
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Christoph Boget | last post by:
I am getting an error (a few among many) for the following lines of code: retval.BrokerName = (( curRow == System.DBNull.Value ) ? SqlString.Null : (string)curRow ); retval.BrokerGroupId = ((...
2
by: Jeff | last post by:
I get the following error: Cannot implicitly convert type 'Factory.Stack.pArrayStack' to 'Factory.Stack.StackDefs.ImStack' at compile time. I thought perhaps there was a mismatch between the...
2
by: Patrick Olurotimi Ige | last post by:
When i convert:- this code from VB to C# Why do i get error "Cannot implicitly convert type 'object' to 'bool' VB --- If cmdcommand.Parameters("ReturnValue").Value = 1 Then lblStatus.Text =...
6
by: eric.goforth | last post by:
What's wrong with this? if (bool)(UserIDs == ThisUserId) { return true; }
6
by: Doug | last post by:
Hi I have a short piece of trial code that compares some input and then produces a message based on the value. However I get a build error that i dont know how to resolve ' Cannot implicitly...
7
by: groups | last post by:
This is my first foray into writing a generic method and maybe I've bitten off more than I can chew. My intent is to have a generic method that accepts a value name and that value will be...
6
by: John | last post by:
The following code: int test = 1; bool isTrue = (bool)test; results in a compiler error: Cannot convert type 'int' to 'bool' wtf, any ideas on how to work around this?
4
by: hellomac23 | last post by:
Hi im trying to write a if...else for C# but i keep getting Cannot implicitly convert type 'int' to 'bool' i really lost can anybody help me on what that means
4
by: cowdung7 | last post by:
public bool searchGame(string gameName) { string searchGame = {"Tibia", "Combat Arms", "Need for Speed", "Moto GP", "Risk", "Red Alert", "Monopoly", "Scrabble"}; if ( searchGame ==...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.