473,809 Members | 2,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

the error shows that cannot implicit int type to bool value

1 New Member
the error shows that cannot implicit convert type 'System.Data.Sq lClient.SqlPara meter' to 'bool'..

here is my code ...


code:


protected void GridView1_Selec tedIndexChangin g(object sender, GridViewSelectE ventArgs e)
{
cmd.CommandType = CommandType.Tab leDirect;
DropDownList id = (DropDownList)s ender;

// e.NewSelectedIn dex["Status"] = (Convert.ToStri ng()id.Selected Value;

// GridViewRow row = GridView1.Rows[GridView1.EditI ndex];
GridViewRow row = GridView1.Rows[GridView1.Selec tedIndex];

cmd.CommandType = CommandType.Tab leDirect;
if(cmd.Paramete rs.AddWithValue ("@Status", txtslry.Text))
{
txtslry.Text = "Yes";

if (id.SelectedVal ue == "Yes")
{
TextBox column1 = (TextBox)row.Fi ndControl("Colu mn1ID");
column1.Visible = true;
TextBox column2 = (TextBox)row.Fi ndControl("Colu mn2ID");
column2.Visible = true;
TextBox column3 = (TextBox)row.Fi ndControl("Colu mn3ID");
column3.Visible = true;
TextBox column4 = (TextBox)row.Fi ndControl("Colu mn4ID");
column4.Visible = true;
TextBox column5 = (TextBox)row.Fi ndControl("Colu mn5ID");
column5.Visible = true;



}

else if (cmd.Parameters .AddWithValue(" @Status", txtslry.Text))
{
txtslry.Text = "No";
}
else if (id.SelectedVal ue == "No")
{
TextBox column1 = (TextBox)row.Fi ndControl("Colu mn1ID");
column1.Visible = false;
TextBox column2 = (TextBox)row.Fi ndControl("Colu mn2ID");
column2.Visible = false;
TextBox column3 = (TextBox)row.Fi ndControl("Colu mn3ID");
column3.Visible = false;
TextBox column4 = (TextBox)row.Fi ndControl("Colu mn4ID");
column4.Visible = false;
TextBox column5 = (TextBox)row.Fi ndControl("Colu mn5ID");
column5.Visible = false;


}
Apr 9 '12 #1
1 2105
Monomachus
127 Recognized Expert New Member
The problem is in your ifs statements cmd.Parameters. AddWithValue will return a System.Data.Sql Client.SqlParam eter, but you want somehow to decide base on it (meaning you want to see a boolean ? ).
Check more about SqlParameter.Ad dWithValue in http://msdn.microsoft.com/en-us/libr...withvalue.aspx
Expand|Select|Wrap|Line Numbers
  1. if(cmd.Parameters.AddWithValue("@Status", txtslry.Text))
  2. {
  3.  
Apr 9 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
1880
by: Johan | last post by:
Hi Can somebody explain to me why I get this warning message and how I can solve this warning message. Thanks a lot Johan In member function `void
3
1989
by: Jon Shemitz | last post by:
Why would you ever want to define both "public static bool operator true" and "public static bool operator false" when you can just define "public static implicit operator bool"? Is there syntax where the two are not equivalent? Or are there cases where you might legitimately want both false and true to return the same value? Fwiw, I'm having a hard time coming up with any C# 1.1 code that calls true or false operators. I'm inclined...
2
2285
by: Jon Shemitz | last post by:
How come I can write code like "if (L)" but NOT code like "if (L == true)" when L is a class with an implicit operator bool? /////////// List L = new List(); public class List { private long count = 0;
6
14569
by: Tim Cartwright | last post by:
I have a page that has the login control on it, nothing else. This page inherits from a master page, neither page has any code in it. This page works perfectly when running on the WebDev debug web server. I am able to log in. However after publishing the page to my local IIS, it results in the below error. This error is occurring on the Visual Studio.Net 2k5 release version, but did not occur on the beta 2, same code. A point of interest, is...
2
14812
by: Paul Hemans | last post by:
I am very new at .Net. I have a small project where I need to manipulate the contents of a web page. I have a form with a web browser control (webBrowser1) on it. Within the webBrowser1_DocumentCompleted method I have the following code. mshtml.HTMLDocument oDoc = new HTMLDocumentClass(); oDoc = (mshtml.HTMLDocument)webBrowser1.Document;
2
17178
by: Marcelo Muzilli | last post by:
Howdy all, in my program, I have a ushort variable and a string variable and if I try to compile it, I'm receiving this error message: "Cannot convert type 'string' to 'ushort'". How can I compare both? Example:
6
30202
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?
1
2024
by: KamalaChandru | last post by:
i got an error "cannot covert the type double to type bool.
2
10289
by: Paulo | last post by:
DataRow dr = (DataRow)ds.Tables.Rows.ItemArray; Error 1 Cannot convert type 'object' to 'System.Data.DataRow' C:\Documents and Settings\Fabio\Meus documentos\Visual Studio 2005\Projects\CodBarraPalm\CodBarraPalm\Default.aspx.cs 35 26 CodBarraPalm ? why this error trying to get the contents of a row on a DataSet?
2
4676
by: nomad | last post by:
Hi, When trying to serialize a class I keep getting the message below. optionalExtensionTypeOptionalExtension is not mandatory so not sure why this is appearing. If anyone has seen this type of error before and found a way around it, it would be greatly appreciated. error CS0030: Cannot convert type
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10640
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.