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

C#NET2008 DataValidation using IF statement

126 100+
Hullo Good Friends,
I am back again seeking help. Please help me.
I am using C#NET2008 Window Application, This is the situation. Should either one of this control, txtXMLFolder.Text , txtXMLName.Text , lblCustID.Text is BLANK, It should not activate FCreateXMLFile() Function.


I am using IF Statement to validate data and it generate this error message to my surprise.

Error 2 Operator '||' cannot be applied to operands of type 'bool' and 'string'

This is the coding that I tried to:
Expand|Select|Wrap|Line Numbers
  1.  
  2. private void btnXML_Click(object sender, EventArgs e)
  3.  {  //validate data pior to create XML File
  4.  
  5.    if ((this.txtXMLFolder.Text == "" ) ||  (this.txtXMLName.Text == "") ||  (this.lblCustID.Text = ""))
  6.     {
  7.      string txtmsg = "Either one of these data is missing" + "\n";
  8.      txtmsg += "Customer Selection" + "\n";
  9.      txtmsg += "XML File Creation" + "\n";
  10.      txtmsg += "Select XML Stored Folder";
  11.  
  12.      MessageBox.Show(txtmsg, "XML Creation Cancelled ");
  13.    }
  14.    else
  15.      {//create XML File 
  16.        FCreateXMLFile();
  17.      }
  18.  } // end btnXML
  19.  
Oct 25 '10 #1

✓ answered by Anton Zinchenko

Expand|Select|Wrap|Line Numbers
  1. private void btnXML_Click(object sender, EventArgs e)
  2.  {  //validate data pior to create XML File
  3.  
  4.    if ((this.txtXMLFolder.Text == "" ) ||  (this.txtXMLName.Text == "") ||  (this.lblCustID.Text == ""))
  5.     {
  6.      string txtmsg = "Either one of these data is missing" + "\n";
  7.      txtmsg += "Customer Selection" + "\n";
  8.      txtmsg += "XML File Creation" + "\n";
  9.      txtmsg += "Select XML Stored Folder";
  10.  
  11.      MessageBox.Show(txtmsg, "XML Creation Cancelled ");
  12.    }
  13.    else
  14.      {//create XML File 
  15.        FCreateXMLFile();
  16.      }
  17.  } // end btnXML
  18.  

2 1509
Expand|Select|Wrap|Line Numbers
  1. private void btnXML_Click(object sender, EventArgs e)
  2.  {  //validate data pior to create XML File
  3.  
  4.    if ((this.txtXMLFolder.Text == "" ) ||  (this.txtXMLName.Text == "") ||  (this.lblCustID.Text == ""))
  5.     {
  6.      string txtmsg = "Either one of these data is missing" + "\n";
  7.      txtmsg += "Customer Selection" + "\n";
  8.      txtmsg += "XML File Creation" + "\n";
  9.      txtmsg += "Select XML Stored Folder";
  10.  
  11.      MessageBox.Show(txtmsg, "XML Creation Cancelled ");
  12.    }
  13.    else
  14.      {//create XML File 
  15.        FCreateXMLFile();
  16.      }
  17.  } // end btnXML
  18.  
Oct 25 '10 #2
lenniekuah
126 100+
Hi Anton,
Thank you very much for sharing information with me.
I followed your sample and my coding is working now.
You are awesome and generous in sharing information.
Appreciate that very much.

I am so glad to meet you here at this Wonderful FORUM
Oct 25 '10 #3

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

Similar topics

3
by: Russell Mangel | last post by:
Is it possible to use the using statement with XmlTextReader? I tryed to use it, but it gives me the error message: Cannot implicitly convert type 'System.Xml.XmlTextReader' to...
5
by: Bill Priess | last post by:
Hey gang, Ok, I'm stumped on this one... I am using the using statement to wrap a SqlDataAdapter that I am using to fill a DataTable. Now, what I need to know is, just how much block-scope...
1
by: Kepler | last post by:
I have a situation where I need to use a Using statement that creates some records in a database. After that completes, if it completes, I need to do some file creation. Any code I'm putting...
8
by: J-T | last post by:
I have a class like below I have a couple of questions about that: 1) I like to use "Using statement" when creating an object of this class,so I had to implement IDisposable.Am I doing this right...
1
by: pascal_pare | last post by:
Hi, Is there a way to declare a using statement with the CodeDom? Something like: using (obj = new Object()) { obj.DoSomething; }
18
by: Trevor | last post by:
I have seen the "using" statement used in strange ways in some C# code. Example: using (StreamReader sr = new StreamReader("TestFile.txt")) { // do some stuff... } What effect does the...
5
by: Andreas Müller | last post by:
Hi, I was wondering, if there is something similar in VB.NET like the using statement in C#. What it does is to automatically call Dispose on the object decrared with in the statement when the...
2
by: Robert Bravery | last post by:
Hi all, Being new to C# and .net I often don't know how to use things. I have created an app that imports excel data, it works well, with methods to open excel, extract the data and close excel....
6
by: Juan Zamudio | last post by:
Hi all, I'm using vs 2003, i have a question about using and as, i was reading in programing .net components that one way to avoid null references inside using was using as, something like this:...
5
by: Hillbilly | last post by:
MSDN Remarks "as a rule" the using statement should be used when instantiating objects which inherit IDisposable. Other than the obvious unmanaged objects like the file system example, fonts and...
1
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: 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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.