Friday, 16 August 2013

Back in Hyderabad, The Hunt is going on......

After i had finished my internship in Inforica I went back to Nagpur for my project work and seminar work. Everything went of well and now i am back in Hyderabad. I came to Hyderabad last week to search for a job since i thought that there are better opportunities in Hyderabad. Let see what will happen. Hope for the best!!!

Sunday, 2 June 2013

Last day of Internship











On the last day of our Internship we were feeling quit relaxed. Inforica is a great company, we had lots of new experiences everyday over here. Sudeep, our boss last month went Cannada for official work, so we got the Project completion Certificate from Shankar Sir.It was really good working with this company. Whatever we did, small tasks or Project work we have learn new things here. Today, I remember the first day when we came to office, we both were too nervous but excited at the same time. The last 4 months went here was really unforgettable. Will miss my desk, my chair, my friends over here and everything. I really want to thank Sudeep for giving me chance to do my Internship here. And as Sudeep said to work hard upon my programming skills, will surely follow his guidelines in future.

Thursday, 9 May 2013

Query String Parameters

     Query String Parameters are used to pass values from one page to another page. Query String parameters are created by using the ? symbol at the end of the url while navigating to a page. Next to ? symbol, specify the parameter nae followed by = operator followed by the value to pass using that parameter. When you have multiple parameters then separate them with & symbol. 
          
                      Server.Transfer("~/page2.aspx?pname=value&pname=value")

To read Query String parameters, use query string property of Request object.

                      Varname=Request.QueryString["pname"]

The following example creates two pages Querystring1.aspx and Querystring2.aspx and withen the 1st page within a gridveiw the details of departments are displayed with select option and when user select a department then the selected deptno will be passed to 2nd page through querystring parameter and within the second page the list of employeees working in that deptnowill be displayed in a gridveiw.

1.  Add a page to the website with the name querystring1.aspx, take a gridview on it, set the id of that gridveiw to Gvdept, set its AutoGenerateSelectButton property to true

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

namespace WebApp
{
    public partial class Querystring1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection cn = new SqlConnection("server=localhost; database=db1;uid=cheryl;trusted_connection=true");
            SqlCommand cmd = new SqlCommand("Select * from dept", cn);
            cn.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            gvdept.DataSource = dr;
            gvdept.DataBind();
            gvdept.DataKeyNames = new string[] { "Deptno" };
            cn.Close();
            dr.Close();
        }
        protected void gvdept_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            gvdept.SelectedIndex = e.NewSelectedIndex;
            string Dno = gvdept.SelectedValue.ToString();
            Response.Redirect("~/Querystring2.Aspx?Dno=" + Dno);
        }
    }
} 
2.  Add another page to the website with the name querystring2.aspx. Place a gridveiw on that page, set its id as GvEmp

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;

namespace WebApp
{
    public partial class Querystring2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string Dno = Request.QueryString["Dno"].ToString();
            string Sql = "Select * from emp where Deptno=" + Dno;
            SqlConnection cn = new SqlConnection("server=localhost; database=db1;uid=cheryl;trusted_connection=true");
            SqlCommand cmd = new SqlCommand(Sql, cn);
            cn.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            gvemp.DataSource = dr;
            gvemp.DataBind();
            cn.Close();
            dr.Close();

        }
    }
}

Wednesday, 8 May 2013

LINQ to SQL (Example)

Example : Add a new form in project and design it as following.



Output :




Coding:


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

namespace LinqProject1
{
   public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        CS11DBDataContext dc;
        List cust;
        int rno = 0;
        private void Form2_Load(object sender, EventArgs e)
        {
            dc = new CS11DBDataContext();
            cust = dc.GetTable().ToList();
            ShowData();
        }
        private void ShowData()
        {
            txtCustID.Text = cust[rno].CustId.ToString();
            txtCname.Text = cust[rno].Cname.ToString();
            txtCity.Text = cust[rno].City.ToString();
            txtBalance.Text = cust[rno].Balance.ToString();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            if (rno0)
            {
                rno -= 1;
                ShowData();
            }
            else
            {
                MessageBox.Show("First record of the table", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        } 
    } 
}

LINQ to SQL

Microsoft has provided LINQ as a lightweight facade that provides a strongly typed interface to the underlying data stores. LINQ provides the means for developers to stay within the coding environment they are used to and access the underlying data as objects that work with the IDE, intellisense, and even debugging. With LINQ the queries you create now become first-class citizens within the .Net framework alongside everything else you are used to. When you work with queries for the data store you are working with, you will quickly realize that they now work and behave as if they are types in the system.

LINQ to SQL in particular is a means to have a strongly typed interface against a SQL Server database. You will find the approach that LINQ to SQL provides is by far the easiest approach to the querying SQL Server available at the momoent. It is important to remember that LINQ to SQL is not only about querying data, but you also are able to perform Insert/Update/Delete statements that you need to perform which are known as CRUD operations (Create/Read/Update/Delete). Visual Studio comes into strong play with LINQ to SQL in that you will find an extensive user interface that allows you to design the LINQ to SQL classes you will work with.

Example : 

Place a DataGridView control on the first Form of project, change the name of DataGridView as gdView and write the following code:

Output:

 

Coding :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Linq;

namespace LinqProject1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            CS11DBDataContext dc = new CS11DBDataContext();
            Table tab = dc.GetTable();
            dgview.DataSource = tab;
        }  
      
    }
}

Tuesday, 7 May 2013

Collections

     Arrays are simple data structures used to store data items of a specific type Although commonly used, arrays have limited capabilities. For instance you must specify an array size, and if at execution time you wish to modify it you must do so by creating a new array or by using array classes resize method, which creates a new array and copies the existing elements into the new array.
     Collections are a set of prepackaged data structures that offer greater capability than traditional arrays. They are reusable, reliable, powerful and efficient and have been carefully designed and tested to ensure quality and performance. Collections are similar to arrays but provide additional functionalities, such as dynamic resizing - They automatically increase their size at execution time to accommodate additional elements, inserting of new elements, removing of existing elements etc.
     Initially .net introduces so many collection classes under the namespace System.Collections like Stack, Queue, LinkedList, SortedList, ArrayList etc.

Monday, 6 May 2013

Query String Parameters

Query String parameters to pass values from one page to another page. Query string parameters are created by using ? symbol at the end of the url while navigating to a page. Next to the ? symbol, specify the parameter name followed by= operator  followed by the value to pass using that parameter. When, you have multiple parameters then seperate them with & symbol.

Server.Trnasfer("~/page2,aspx? pname=value& pname=value");

To read query string parameters, use QueryString property of Request object.

Varname=Request.QueryString["pname"];