Linq to SQL Connection in asp.net Csharp

29. June 2010

In this Example, I have Create a connecton string and establish a connection between object to database. and Select title from employees table.

string connectionString = "Data Source=.;Initial Catalog=Northwind;Integrated Security=True";
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            using (NorthwindDataContext context = new NorthwindDataContext(connection))
            {
                var query = from c in context.employees
                            select c.Title;

                foreach (var title in query)
                {
                    Response.Write(title);
                }
            }


Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL, asp.net, asp.net 4.0 ,

get Max Value With LINQ To SQL

27. June 2010

In MS SQL Syntax

SELECT MAX(COLUMN NAME) FROM [TABLE NAME]

 

In Linq to SQL Syntax

var maxValue = ( from q in [TABLE NAME] SELECT (P.[COLUMN NAME]).Max()

 

 



Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL ,

How to Delete Duplicate Rows from a table

25. June 2010

In this Example, i will tell you how to delete a duplicate rows from a table.

DELETE FROM [TABLE NAME] 
WHERE ID NOT IN (select MAX(ID) FROM [TABLE NAME] 
GROUP BY [DUPLICATE COLUMN NAME])


Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL, SQL Injection ,

Parameter Name asp.net 4.0 New feature

25. June 2010

Another new feature in 4.O FrameWork, Name Parameter,Let see in the Below Sample how to pass the parameter.

 

protected void Page_Load(object sender, EventArgs e)
   {
   	foreach (int i in Add( n1:20,n2:60))
   	{
   		Response.Write(i.ToString() + " ");
   	}
   }
  

 public static IEnumerable Add(int n1, int n2)
 {
 
 return i*i;
 
 }


Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL, asp.net, asp.net 4.0, CSharp ,

upload control not work in Update Panel

18. June 2010
Yesterday i was working online, Some one ask me that he is facing a problem that File upload control is not working with in Update Panel. So dont worry, Below is the solution.
Form must be encod with multipart/form-data. Change the form attribute to encoded as shown below line of code.

Page.Form.Attributes.Add("enctype", "multipart/form-data");


Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL, asp.net ,



User Name: Guest

Your Ip: 38.107.191.92
Time: