-->

Sunday, February 28, 2016

How to design finger print/ scanner based project in C#

In this article, I will show you, how to compare two images in c#. You can say that how to match prints images in c#. Basically, this types things we can implement in biometric systems like fingerprint etc. If you want to work on this system, follow these mentioned steps to complete this task.


Step-1:  Create a windows form project using Visual Studio, you can take any version of visual studio.

Step-2:  Design output type form in default added file ie. form1

Step-3:  Copy and Paste mentioned code, according to their controls

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Fingure_print
{
    public partial class Form2 : Form
    {
        Bitmap bitmapPictureBox1;
        Bitmap bitmapPictureBox2;
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {

                pictureBox1.ImageLocation = openFileDialog1.FileName;

                bitmapPictureBox1 = new Bitmap(openFileDialog1.FileName);
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {

                pictureBox2.ImageLocation = openFileDialog1.FileName;

                bitmapPictureBox2 = new Bitmap(openFileDialog1.FileName);
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            bool compare = ImageCompareString(bitmapPictureBox1,bitmapPictureBox2);
            if(compare==true)
            {
                MessageBox.Show("match");

            }
            else
            {
                MessageBox.Show("not");
            }
        }
        public static bool ImageCompareString(Bitmap firstImage, Bitmap secondImage)
    {
       MemoryStream ms = new MemoryStream();
        firstImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
        String firstBitmap = Convert.ToBase64String(ms.ToArray());
       ms.Position = 0;
   
       secondImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
        String secondBitmap = Convert.ToBase64String(ms.ToArray());
 
      if (firstBitmap.Equals(secondBitmap))
      {
         return true;
     }
       else
       {
          return false;
     }
   }
    }
}

Code Generates the following output
How to design finger print/ scanner based project in C#





Saturday, February 27, 2016

Blood bank System project in ASP.NET C#

Introduction
The blood bank system provides some information about blood bank. A needy person can take some points of blood with their blood groups. By using this system, we provides the information  about donor and takers. These all information are public. Any one  person register in the control panel and after successfully register in the panel. He/She can login in the system. We have a form for donor, in this form, donor fill these mentioned fields.

Donor Id :  Int type
Name :  nvarchar (100)
Blood Group :  nvarchar ( 50)
Contact ( Phone Number)  : nvarchar (50)
Address : nvarchar(max)
Picture:  nvarchar(max)

Blood bank System project in ASP.NET C#


After filling the form, information display on home screen, registered user can see donor information. Project also provide the search facility, through it, registered user can see donor information, according to blood group. It provide the total storage of blood in the bank. Bank takes blood from outer side also vice versa. Total in and out details stored in separate database table.

Software information : Visual Studio 2013
Hardware requirement :  Visual Studio 2013 compatible hardware.

Video : Comming Soon

How to run it: You can run it using video help.

Download/Buy : mail me narenkumar851@gmail.com




Thursday, February 25, 2016

GridView rows details on DetailsView using onSelectedIndexChanged event in ASP.NET C#

Bind Details view using onselectedIndexChanged event of Gridview view. First to Bind the Gridview with select command. By using selectedIndexChanged method you can bind the details view. If you want to bind the DetailsView from Gridview Row then use select command name in GridView's button field name. In the Code behind file, first to bind the Gridview from database table. Retrieve the selected Row data using select command, bind DataTable with Retrieved data.


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
            <Columns>
                <asp:BoundField DataField="Id" HeaderText="ID" />
                <asp:BoundField DataField="name" HeaderText="Name" />
                <asp:TemplateField HeaderText="address">
                    <ItemTemplate>

                        <asp:Label ID="addlabel" Text='<%# Eval("address") %>' runat="server" />

                    </ItemTemplate>
             

                </asp:TemplateField>
                <asp:ButtonField Text="select" CommandName="select" />
            </Columns>


        </asp:GridView>
        <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" AutoGenerateRows="false">
            <Fields>
                <asp:BoundField DataField="Id" HeaderText="ID" />
                <asp:BoundField DataField="name" HeaderText="Name" />
                <asp:BoundField DataField="address" HeaderText="Address" />


            </Fields>


        </asp:DetailsView>
    </div>
    </form>
</body>
</html>

Code Behind Code

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            SqlConnection con = new SqlConnection();
            con.ConnectionString = ConfigurationManager.ConnectionStrings["myconnection"].ToString();
            con.Open();
            SqlCommand cmd=new SqlCommand();
            cmd.CommandText="select * from [Registration]";
            cmd.Connection=con;
            SqlDataReader rd = cmd.ExecuteReader();
            GridView1.DataSource = rd;
            GridView1.DataBind();

        }

    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int id= int.Parse(GridView1.SelectedRow.Cells[0].Text);
        string name = GridView1.SelectedRow.Cells[1].Text;
        string add = (GridView1.SelectedRow.FindControl("addlabel") as Label).Text;
        DataTable dt = new DataTable();
        dt.Columns.AddRange(new DataColumn[] { new DataColumn("ID", typeof(int)), new DataColumn("Name", typeof(string)), new DataColumn("Address", typeof(string)) });
        dt.Rows.Add(id, name, add);
        DetailsView1.DataSource = dt;
        DetailsView1.DataBind();
    }
}

Code Generates the following output
GridView rows details on DetailsView using onSelectedIndexChanged event in ASP.NET C#

Saturday, February 20, 2016

Banking Software Application Project in c#

Introduction
Purchase Banking software project built in window platform. By using this software, we can do banking task easily. In this project,  I have to provide you banking functionality like Create new account, update customer account, deposit money, transfer money etc. I will give you project executable file to run the project. If you want to learn how to design this project then follow these mentioned steps:

[Video Describe full details]



  1. Start from Login screen. If admin username exists in database table then loginIn into the system else give failed message.
banking System Login Failed Screen

2. If login success then enter in main screen.

Banking Software Application Project in c#

3. Similarly all option which is given in the project.


Requirement
Software : Visual Studio 2013. 


How to run you project
Double click on application executable file and run your project.

How to design Banking Software
First to create a login form for Administrator. After successfully login, administrator can do some work in the control panel like:

  1. Add New Customer.
  2. Deposit money to customer bank account.
  3. Transfer money from one account to another account.
  4.  Show list of account which is available in the bank.
  5. Withdrawal amount from account number by the account holder.
  6. Generate balance sheet.
  7. FD form for customers.
Download : mail me : narenkumar851@gmail.com

Thursday, February 18, 2016

How to retrieve items from database table in JAVA using Netbeans

In this article i will explain you, how to retrieve items from database table in Java using Netbeans. In previous article, we have already learned, how to create connection with the derby database using netbeans. Before reading this article, please must to see the previous article for implementations. In this article, i only explain you, how to use executeQuery( ) method and select statement in java.

--How to create connection with database full video tutorial 


Code :

class abc {
    public abc() throws SQLException
    {
        Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/student", "tarun", "tarun");
        System.out.println("Connection Created");
        Statement st=conn.createStatement();
        ResultSet rs=st.executeQuery("select * from USERTABLE");
        while(rs.next())
        {
            System.out.println(rs.getString(2));
        }
   
    }

}

Here, we have a table i.e USERTABLE. If you want to learn how to create table in exists database using Netbeans. Read mentioned steps:
Step-1 :  Right click on Connection String, select "connect" from popup menu.
Step-2 :  Expand username which contains Tables, views and stored procedure.
Step-3 :   Right click on table, select create table.


Write the name of table also add columns with their datatypes. 

How to use mouseenter( ) and mouseleave( ) method in JQuery

The meaning of mouse enter and mouse leave are, when your cursor enter your object bounary then mouse enter method raised similarly when your cursor goes out of your object boundary then mouse leave method raised. I will give you an example of mouse enter and mouse leave method. Lets see the example, in this, we have division, when your cursor move on your divison boundary then division background changed also text of division will be changed. This also contain mouseleave() method with the same functionality.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default22.aspx.cs" Inherits="Default22" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.10.2.js"></script>
    <script>
        $(document).ready(function()
        {
            $('div').mouseenter(function () {
                $(this).css('background-color', 'green');
                $(this).html('MY website dotprograming.com')
            });


            $('div').mouseleave(function () {
                $(this).css('background-color', 'red');
                $(this).html('MY Blog dotprogramming.blogspot.com');
            })

        })

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div style="height:50px;width:50px">
    Hello World !
    </div>
    </form>
</body>
</html>

Code generates the following output



Wednesday, February 17, 2016

How to create Database connection in JAVA using Netbeans

If you want to connect database with your java application then first to need a database. First to create database using Netbeans services tab. This tab available under Windows tab. You can also select this tab by using shortcut CTRL+ 5.


services tab in netbeans


  1. Expand the databases tab, select "Create Database." option. 
create database in netbeans

2. Fill fields which are shown under diagram.

Database fields in Netbeans
 3. After filling the form, you have to create database successfully.
 4. Right Click on your connection string name, select properties for copy the database URL.

java netbeans database properties

5. Copy Database URL, which is used further.

netbeans database properties
6. Create a new java project under projects tab. 
7. Add a Library in the "Libraries" section of your project.
add libraries in projects
8. Select Java DB Driver under Add Library section.

JAVA DB Drivers
9. Open your .java file which is exists in java packages folder of your project. 
10. Create a another class object, which is exists in same package.
11. Now, Open the object class, create constructor in it.
12. paste the code under the constructor.

Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/jk", "jk", "jk");
        System.out.println("connection created"); 

Here we have three parameters in getConnection method. 
First refer to database url ; according to 5th step.
Second : Username 
Third :  password.

Tuesday, February 16, 2016

ASP.NET ListBox Insert Multiple selected item into database

In this article, I will show you how to insert multiple selected item in  database table. I have already done one projects on this topic i.e online movie ticket booking system. In this project, i selected multiple tickets by using comma symbol in TextBox. The same article i will do in different manner. In this we have a ListBox with multiple selection mode.
What i do in code behind :

  1. Store the selected of ListBox items to the string type list.
  2. For the each item, i will create a Query statement, Suppose your List contain two items i.e "Apple" and "Mango", Both are selected then use String builder class to Append Query.
  3. Like "insert into [tablename] (fruitname)values('Apple')";  and for second item  "insert into [tablename] (fruitname)values('mango')";

Source Code

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="multipleselect.aspx.cs" Inherits="multipleselect" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
        <asp:ListBox ID="ListBox1" runat="server" Height="100px" SelectionMode="Multiple" Width="174px">
            <asp:ListItem>Apple</asp:ListItem>
            <asp:ListItem>Grapes</asp:ListItem>
            <asp:ListItem>Orange</asp:ListItem>
            <asp:ListItem>Mango</asp:ListItem>
            <asp:ListItem>Pea</asp:ListItem>
        </asp:ListBox>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Save" />
    </form>
</body>
</html>

Code Behind Code

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class multipleselect : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        List<string> l1 = new List<string>();
        foreach (ListItem item in ListBox1.Items)
        {
            if (item.Selected)
            {
                l1.Add(item.Text);
            }  
        }
        recordinserted(l1);
    }

  

    private void recordinserted(List<string> l1)
    {
       StringBuilder stringbi = new StringBuilder(string.Empty);
        foreach (string item in l1)
{
const string qry = "insert into [Fruits](FruitName)values";
            stringbi.AppendFormat("{0}('{1}');",qry,item);
}
        //throw new NotImplementedException();
        SqlConnection con = new SqlConnection();
        con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionStringtr"].ToString();
        con.Open();
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = stringbi.ToString();
        cmd.Connection=con;
        int a= cmd.ExecuteNonQuery();
        if(a>0)
        {
            Response.Write("inserted");
        }
    }
}

Code Generates the following output : 


ASP.NET ListBox Insert Multiple selected item into database

Wednesday, February 10, 2016

By using Single LINQ Query retrieve foriegn key table column

In this article, I will explain you, How to retrieve data from two joined table using single LINQ Query. Here we have two joined table in mentioned diagram. Both tables are joined from dept_no, so if you want to retrieve record from both table like:
Retrieve emp_id and emp_name who belongs to IT department.



employeeEntities empl = new employeeEntities();

            var query = from g in empl.emps
                        join m in empl.depts on g.dept_no equals m.dept_no
                        where m.dept_name == "IT"
                        select new
                        {
                            Emp_Name = g.emp_name,
                            Emp_ID = g.emp_id
                        };
               
            dataGridView1.DataSource = query.ToList();
In this code, empl is the context object through which we can access columns of both tables. emp is the foreign key table map with dept table using dept_no column. Emp_Name and Emp_ID is the reference name , which are displayed on table. Bind the query result with the dataGridView. 

Tuesday, February 9, 2016

[Solved] Rows cannot be programmatically removed unless the DataGridView is data-bound to an IBindingList that supports change notification and allows deletion.

[Solved] Rows cannot be programmatically removed unless the DataGridView is data-bound to an IBindingList that supports change notification and allows deletion. When you bind the Datagridview with List in windows form. You get error when you delete row from it. According to article title, first to implement your List from IBindingList interface, if you want to solve this issue. Suppose, you want to bind your DataGridView with this class, which is mentioned below:

public partial class userAccount
    {
        public decimal Account_No { get; set; }
        public string Name { get; set; }
         }
    }

Then you write simple code for this :

List<userAccount> ua= new List<userAccount>();
ua.Add(new userAccount(){Account_No=1000000008, Name ="Jacob"});
dataGridView1.DataSource = ua;

After binding the DataGridview, you will write the code for remove row from dataGridview.

dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[0].Index);

After that you got error, which is mentioned below:

[Solution]

Bind DataGridView with IBindingList<userAccount> . Now the code is:

BindingList<userAccount>  bi = new BindingList<userAccount> ();
bi.Add(new userAccount(){Account_No=1000000008, Name ="Jacob"});
dataGridView1.DataSource = bi;

After binding the DataGridview, you will write the code for remove row from dataGridview.

bi.RemoveAt(dataGridView1.SelectedRows[0].Index);

Monday, February 8, 2016

Login username password saved in cookies

We all know about login form. In it, we have two fields first and second  that are username and password. Both are stored in browser memory via HttpCookie. I mean to say when you first-time login into your account your username and passwords are saved into your browser cache. So, when you come again on your website, it did not ask username and password again, redirect on home page.


Before reading this article, if you want to know about cookie then watch mentioned video.Now,  Lets start to save username and password in the cookies. 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="logincookies.aspx.cs" Inherits="logincookies" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        UserName :
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />
        Password&nbsp;&nbsp; :
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Login" />
&nbsp;<asp:CheckBox ID="CheckBox1" runat="server" Text="Keep Me Sign in" />
    
    </div>
    </form>
</body>
</html>

Code-Behind File 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class logincookies : System.Web.UI.Page
{
    string uname = "admin";
    string pass = "pass";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Cookies["authcookie"]!=null)
        
        {
            if (Request.Cookies["authcookie"]["username"] == uname && Request.Cookies["authcookie"]["password"] == pass)
            {
                Response.Redirect("~/mainpage.aspx");
            }
            
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (TextBox1.Text == uname && TextBox2.Text == pass)
        {
            if (CheckBox1.Checked)
            {
                Response.Cookies["authcookie"]["username"] = TextBox1.Text;
                Response.Cookies["authcookie"]["password"] = TextBox2.Text;
                Response.Cookies["authcookie"].Expires = DateTime.Now.AddDays(2);

            }
            Response.Redirect("~/mainpage.aspx");
            
        }
    }
}

Code Generates the following output:

Login username password saved in cookies
In this code we have a code in page load method. First to check, either Cookies are available or not. If cookies are available then check the username and password which are stored in the cookies. If both are matched then redirect to another page. When we click on button then first to match the username and password, if both are matched then saved the username and password into the cookies.


Saturday, February 6, 2016

Refreshing / reloading of pages and delayed redirect using Meta tags in ASP.Net c#

In this article, I will explain you, how to reload page after few seconds. This types of logics appear where web page refresh just after few seconds like yahoo cricket. By using Meta tag, we can implement in web technologies. I will give you an example of it. This article cover such things like :
Watch full code video

  1. Page Reload/ Refresh after 10 seconds.
  2. By using code we can do reload/ refresh page.
  3. By using AppendHeader( ) method we can solve this query.
  4. Redirect after 5 seconds to new page.
  5. Redirect page after session out.
Refreshing / reloading of pages and delayed redirect using Meta tags in ASP.Net c#

By using meta tag's attribute, we can refresh webpage, in which we have two attributes i.e http-equiv and content. Let's, take an example:

<head runat="server">
    <title>Meta Tags Example</title>
     <meta http-equiv="Refresh" content="10" />
</head>

We can do this thing by using c# code. By using HtmlMeta class's property, we can also refresh page just after 10 seconds.

C#

protected void Page_Load(object sender, EventArgs e)
{
    HtmlMeta meta = new HtmlMeta();
    meta.HttpEquiv = "Refresh";
    meta.Content = "10";
    this.Page.Header.Controls.Add(meta);
}

By using AppendHeader method we can do the same things.

C#

protected void Page_Load(object sender, EventArgs e)
{
    Response.AppendHeader("Refresh", "10");
}


If you want to do redirect page after few seconds then you should use meta tag at compile as well as runtime. In compile time, you can use meta tag with similar attribute which is defined in above code. The only one difference in both code i.e URL. URL pass in content as a attribute with some interval. Like:

Compile time : 
<head runat="server">
       <meta http-equiv="Refresh" content="10;url=Default.aspx" />
</head>

You can do the same code using c#

protected void Page_Load(object sender, EventArgs e)
{
    HtmlMeta meta = new HtmlMeta();
    meta.HttpEquiv = "Refresh";
    meta.Content = "10;url=Default.aspx";
    this.Page.Controls.Add(meta);
}

II-Method

protected void Page_Load(object sender, EventArgs e)
{
    Response.AppendHeader("Refresh", "10;url=Default.aspx");
}

If you want to out your page after session out then you can replace seconds with Session.Timeout property.

Friday, February 5, 2016

Blocked fake download button websites by Google

Thanks to google for blocking sites which  contain deceptive material and fake download button. Many sites owners focus on ads and fake clicks. So they put download button just after important information, suppose your article is related to project download and you put download advertisement in place of actual download link. When visitor comes on your website and they click on advertisement. The whole deceptive material banned by google's safe browsing tech. By using this ,you can protect yourself or computer from malware and unwanted software.

Blocked fake download button websites by Google
Source : http://arstechnica.com/
  

Google already banned those site which contain wrong information and unwanted Softwares, you can say which breaks "Social Engg attacks".  

Thursday, February 4, 2016

How to use JavaScript in Master Page ContentPlace Holder in ASP.NET

In this article, I will explain you, How to use JavaScript code in ContentPlaceHolder of Master page. If your web page (Web Form=.aspx page)  is inherit from master page then you must to use ClientID of the control to get the value. Like

document.getElementById("<%=Label1.ClientID%>");

By using above mentioned code we want to retrieve inner html text of the label. If you are using java script in simple web form which is not inherit from master page then you can use simple id of the control as parameter. Like

document.getElementById("Label1");

How to use JavaScript in Master page's Content PlaceHolder

Step-1 :  Add a Master page also add web form.
Step-2 :  Do Inherit web form from master page.
Step-3 :  Write the below mentioned code in the content place holder of the web form.

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    <input id="Button1" type="button" value="button" onclick = "check()"/>
    <script type = "text/javascript">
        function check()
        {
             var label = document.getElementById("<%=Label1.ClientID%>");
             var textbox = document.getElementById("<%=TextBox1.ClientID%>");
             alert("Label Value " + label.innerHTML + "TextBox Value  " + textbox.value);
           
        }
    </script>
</asp:Content>

Note: Please mentioned javascript code at last position of the page.


Tuesday, February 2, 2016

How to use ExecuteScalar method in ASP.NET c#

This method returns integer type value, actually, it returns top tuple no of record from the table. Here I will provide you an example of ExecuteScalar ( )  method. By using this example you can retrieve top tuple no from the record. 

Source Code

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:Label ID="Label1" runat="server"></asp:Label>
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Get Record" />
    
    </div>
    </form>
</body>
</html>

CodeBehind Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

public partial class GetfirstRecord : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection();
        con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionStringtr"].ToString();
        con.Open();

        SqlCommand cmd=new SqlCommand();
        cmd.CommandText="select * from [user_table]";
        cmd.Connection=con;
        int a = Convert.ToInt32(cmd.ExecuteScalar());
        Label1.Text = a.ToString();
    }
}

Code Generates the following output:

How to use ExecuteScalar method in ASP.NET c#

© Copyright 2013 Computer Programming | All Right Reserved