Tuesday, 8 April 2014

Window Form/Window application Tutorial

.

Connect sql server with windows application

In This tutorial we will learn how to connect sql server with windows application

Create a login form with Sql Server

Here we will learn how to create a login form with Sql Server

Password protection using code.

In This tutorial we will learn how we do password protection using code.

Use of Group Box and Picture Box in window form.

Here we will learn how to use of Group Box and Picture Box in window form.

Open second from using first form in window form

In This tutorial we will learn how to open second from using first form in window form

SQL server database connection in Window Form


                                                                                                                                          Next

I will start first Tutorial with SQL server database connection. Here i will explain step by step. follow these steps.
step (1):- create a window form
Open visual stdio and create a new project and select window form application and give it name as First_Csharp app.

step (2):- Drag and down a button
now from tool box drag and down a button and click on button

step (3):-Database table
create a database table in sql server. here database name is windowapp and tablename is data


step (4):-Coding on button click
first insert a namespace "using System.Data.SqlClient".
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace First_Csharp_app
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                String str = "server=MUNESH-PC;database=windowapp;UID=sa;password=123";
                String query = "select * from data";
                SqlConnection con = new SqlConnection(str);
                SqlCommand cmd = new SqlCommand(query, con);
                con.Open();
                DataSet ds = new DataSet();
                MessageBox.Show("connect with sql server");
                con.Close();
            }
            catch (Exception es)
            {
                MessageBox.Show(es.Message);

            }
        }
    }
} 
step (5):-Run the application 
                                                                                                                                          Next



C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...