Monday, June 25, 2012

Joining 3 Tables in SQL Server AND My sql

Continuing the previous post  add another table designation in the family DB as shown below.

 create table designation
(
    sno int primary key identity(1,1),
    adultid int,
    designation varchar(250)
)

Joins in SQL Server AND My sql

Joining tables in SQL Server and My sql is equal, so there is no need to confuse here.
Ket us start with creating 2 tables with the database name as family

1. Create Table  name as adults as shown below

create table adults
(
    adultid int primary key identity(1,1),
    adultname varchar(250)
)
2. Create another Table  name as child as shown below

create table child
(
    childid int primary key identity(1,1),
    childname varchar(250),
    adultid int
)

Tuesday, June 19, 2012

send sms to Multiple Numbers using way2sms / 160by2 Desktop Application using C#

In the Previous Application there is no way to send SMS for multiple people, but now you can send SMS for multiple people at a time....

Application features....
  • Saves the time and cost you spend logging into the website
  • Allows you send to GROUP SMS to your friends, employees.
  • Gives you the flexibility to send BULK SMS in just a single click
  • Easily operated right from your desktop.



 To send SMS to multiple users use coma ",".

EX : - 9879879876,9856898698,.....,....

Click Here to Download

Wednesday, June 6, 2012

Attach .mdf file to SQL server using SQL Server Management Studio

In this post i am going to explain, how to attach a *.MDF file to SQL Server 2005/2008
using SQL Server Management Studio.

In this post i will show how to attach a Northwnd database file.

First ADD the two files that is
1. northwnd database file and
2. northwnd log file (not necessary mostly)

and paste in the below location

Thursday, May 31, 2012

Insert, Update and Detele in Entity Framework using C#.Net

Hi this post is regarding EntityFramework where we can can do simple queries like Select, Edit, Update and Delete using EF (EntityFramework). EF is an Object-Relational Mapper.

     First create a database, Don't worry i am uploading the database file also just attach the db file and use it. 
How to attach DB can be seen HERE

1. Open VS 2010 and create a new web project.
2. Ones the web project was created, the first thing we need to do is ADD a new item from installed templates      in vs 2010. Here the new item is ADO.Net Entity Model with an extension *.edmx.
     In my project EFDB  is my file name. ones it was added EFDBEENTITY is the class name to create
     an object, to work with it.
3. while adding a new item it will ask for a connection, provide appropriate things and add the tables you need.
4. Now build the project ones.
5. Design the GUI for adding deleting updating, editing and selecting, now i didnt had a chance to show the
    screen shots for u. Download the project from the provided link.
6. After designing the GUI we had 5 buttons and 7 text boxes and a gridview to show the details.
7. CODING

Bulk Insert Into SQL Table using BulkCopy from DataTable

In the previous post ADD, Delete and Update in datatable was posted. Now continuing the previous post for Bulk Insertion from DataTable you can write the following code in a button click to insert into SQL datatable as shown below.

This is a method as shown

private void Bulkinsert()
    {
        using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings[
           "MyConnectionString"].ConnectionString))
        {
            cn.Open();
            using (SqlBulkCopy copy = new SqlBulkCopy(cn))
            {
                copy.ColumnMappings.Add(0,0);
                copy.ColumnMappings.Add(1, 1);
                copy.ColumnMappings.Add(2, 2);
                copy.DestinationTableName = "TableName";
                copy.WriteToServer(dt);
            }
        }
    }

Insert, Update and Detele in DataTable using C#.Net

Inserting, Deleting and Updating in DataTable is very important in the real senario, with out interation to database every time.
So first i am  creating a datatable in the pageload and this datatable is binded to gridview.
Before that declare static datatable globally as shown below

static DataTable dt;

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            dt = new DataTable();
            dt.Columns.Add("S.NO");
            dt.Columns.Add("Name");
            dt.Columns.Add("Sal");           
            for (int i = 0; i < 10; i++)
            {
                dr = dt.NewRow();
                dr["S.No"] = (1 + i);
                dr["Name"] = "Sample " + (i+1);
                dr["Sal"] = "27000";
                dt.Rows.Add(dr);
            }
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
    }