Monday, October 20, 2014

Sql commands and its types

Intoduction: In this article today I am going to explain Sql commands and its types.

Description:

Sql commands are the set of instructions which are connect/ interact with database to perform specific task.
Types of Sql command:
 Sql commands are grouped into five (5) major categories depending on their functionality. 

Tuesday, October 14, 2014

Copy data from one table to another existing table in sql server

Introduction: In this article today I will explain how we can copy data from one table to another existing table sql server
Description:  
Insert into Table2 Select * from Table1;
Syntax to copy only columns:
Insert into table2(Columns_Name, Columns_Name) select Columns_Name, Columns_Name from from table1;
Note: Here in the above query we select data from table 1 and insert it into table 2. Table 1 will be source and table2 will be target table

Example:

I have two tables:
Old_Student :
Create table Old_Student
(
Id int not null primary key,
Student_Name varchar(50),
Student_Address varchar(50),
Phone_No int
)
New_Student:
Create table New_Student
(
NId int not null primary key,
NStudent_Name varchar(50),
NStudent_Address varchar(50),
NPhone_No int
)
Here now I want to copy the record from New_Student table and insert into Old_Student.
Insert into dbo.Old_Student(Student_Name,Student_Address,Phone_No) select NStudent_Name,NStudent_Address,NPhone_No from dbo.New_Student;


Is this article helpful for you?
If yes post your comment to appreciate my work and fell free to contact me. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.

Friday, October 10, 2014

Move items from one listbox to another listbox and vice versa in asp.net

Introduction: In this article today I will explain how we can move items from one listbox to another listbox and vice versa in asp.net
Description:
I have added the two listboxes to webform. One listbox contain the country name and second one city name.  In this example I have move single item from country listbox to city listbox and vice versa. Also move all items to between each other.
Design the page as Html Markup shown below:
<fieldset>
    <legend>ListBox Example</legend>  
    <table style="height: 168px; width: 279px">
    <tr><td>  <asp:ListBox ID="lstbcountry" runat="server" SelectionMode="Multiple"
            Height="102px" Width="99px">
        <asp:ListItem>India</asp:ListItem>
        <asp:ListItem>England</asp:ListItem>
        <asp:ListItem>Cuba</asp:ListItem>
        <asp:ListItem>Russia</asp:ListItem>
        <asp:ListItem>Singapore</asp:ListItem>
        </asp:ListBox></td>
    <td colspan="2">
        <asp:Button ID="Button1" runat="server" Text=">" onclick="Button1_Click" />      
        <br />
        <asp:Button ID="Button3" runat="server" Text=">>" onclick="Button3_Click" />
        <br />
        <asp:Button ID="Button2"
            runat="server" Text="<" onclick="Button2_Click" />
        <br />
        <asp:Button ID="Button4" runat="server" Text="<<" onclick="Button4_Click" />
        </td>
    <td><asp:ListBox ID="lstbcity" runat="server" SelectionMode="Multiple"
            Height="96px" Width="97px">
        <asp:ListItem>Delhi</asp:ListItem>
        <asp:ListItem>London</asp:ListItem>
        <asp:ListItem>Tokyo</asp:ListItem>
        <asp:ListItem>Boston</asp:ListItem>
        <asp:ListItem>Moscow</asp:ListItem>
        </asp:ListBox></td></tr>
    </table>
       </fieldset>

Tuesday, October 7, 2014

Get multiple selected values from Listbox in asp.net

Introduction: In this article today I am going to explain how we can get multiple selected values from Listbox in asp.net
Description:

Design the webform as given below:
  <fieldset style="width:450px">
    <legend>Listbox Example</legend> 
    Country :
<asp:ListBox ID="lstcountry" runat="server" Width="100px" SelectionMode="Multiple">
            <asp:ListItem>India</asp:ListItem>
            <asp:ListItem>China</asp:ListItem>
            <asp:ListItem>Cuba</asp:ListItem>
            <asp:ListItem>Other</asp:ListItem>
        </asp:ListBox>
        <br /> 
        <br />
<asp:Button
            ID="btnsubmit" runat="server" Text="Get Value" onclick="btnsubmit_Click" /> 
        <asp:Label ID="lblmessage" runat="server"></asp:Label> 
    </fieldset>