473,402 Members | 2,064 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,402 software developers and data experts.

How to use validations for windows application with c#?

Hi All,

How to use validations for windows application with c#. I have kept "error provider" for two text box validation. It is showing error, But at the same time record also saving in to database.Once all the fields is field then only record will be save in to database. And how to add required validation for combo box? Please find the attached code document.

Thanks and regards,
Murali.
Attached Files
File Type: docx Validations.docx (16.3 KB, 472 views)
Dec 10 '12 #1
1 2684
I tried like this , it's working fine.


Expand|Select|Wrap|Line Numbers
  1. if (txtAddress.Text != "")
  2. {
  3. if (txtPincode.Text != "")
  4. {
  5.  
  6. if (txtcity.Text != "")
  7. {
  8.  
  9. SqlConnection con = new SqlConnection(strConn);
  10. con.Open();
  11. SqlCommand cmd = new SqlCommand("sp_rm_insert_basicfamily", con);
  12. cmd.CommandType = CommandType.StoredProcedure;
  13. cmd.Parameters.AddWithValue("@FamilyID", txtFamilyid.Text);
  14. cmd.Parameters.AddWithValue("@HHID", txtHeadofhousehold.Text);
  15. cmd.Parameters.AddWithValue("@Religion", cbxReligion.SelectedValue);
  16. cmd.Parameters.AddWithValue("@Caste", cbxCaste.SelectedValue);
  17. cmd.Parameters.AddWithValue("@HouseNo", txtHouseno.Text);
  18. cmd.Parameters.AddWithValue("@Address1", txtAddress.Text);
  19. cmd.Parameters.AddWithValue("@Village", txtcity.Text);
  20. cmd.Parameters.AddWithValue("@State", cbxState.SelectedValue);
  21. cmd.Parameters.AddWithValue("@District", cbxDistrict.SelectedValue);
  22. cmd.Parameters.AddWithValue("@Mandal", cbxMandal.SelectedValue);
  23. cmd.Parameters.AddWithValue("@Pincode", txtPincode.Text);
  24. cmd.ExecuteNonQuery();
  25. con.Close();
  26. MessageBox.Show("Successfully Saved");
  27. }
  28.  
  29. else
  30. {
  31. MessageBox.Show("Please enter city");
  32. }
  33. }
  34.  
  35. else
  36. {
  37. MessageBox.Show("Please enter pin code");
  38. }
  39. }
  40.  
  41. else
  42.  
  43. {
  44.  
  45. MessageBox.Show("Please enter address");
  46.  
  47. }
Dec 10 '12 #2

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

Similar topics

5
by: joseph | last post by:
Hi, I would like to run a windows application without the user interface. Console application is not a choice because it does not allow to use ADO controls. When I start the Windows Application I...
3
by: Michael | last post by:
Hi, I have a windows service developed using c# and it needs to lunch another windows application. I have been trying to use Process class to do it but the problem is becase windows service...
3
by: RBarryYoung | last post by:
How can I get the following two features in the same program in VS2005?: 1) Access to the command-line arguments (cmdArgs()) that started my App. 2) Shutdown Mode = "When last Form exits". ...
1
by: lavu | last post by:
I currently have a C# windows Application . I would like this App to work through an command line interface also. I would like to specify command line params, which should start the app and process...
4
by: Gav | last post by:
Hi, I am writing a windows form application (C#) which access's data from an SQL server. The SQL server is using windows authentication only. At the moment I have to grant the domain users...
3
by: illegal.prime | last post by:
Hi all, I have a service that needs to start a regular windows application. I'm running the service as ServiceAccount.LocalSystem. But, when it starts the process (using Process.Start) the GUI...
1
by: =?Utf-8?B?d2lubGlu?= | last post by:
Hello Using VS 2005 VB.net when a class library gets created you can right click the project and add a Windows Application and then set it as the "startup project" then in the Windows...
2
by: =?Utf-8?B?dmlzaHJ1dGg=?= | last post by:
Hi, I have 2 applications running, one Windows application project and the other windows services project. I want to call my Windows application in my windows services. I want to run them as...
1
by: =?Utf-8?B?dmlzaHJ1dGg=?= | last post by:
Hi, I have 2 applications running, one Windows application project and the other windows services project. I want to call my Windows application in my windows services. I want to run them as...
1
by: BobLewiston | last post by:
I tried to compile a Windows Forms Application in Visual C# 2008 Express with this source code from the CSharpSchool tutorial at Programmer's Heaven:using System; using System.Windows.Forms; using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.