Developers Archive for the 'dot net c# development' Category

C# preventing more than one application instance at a time

C# preventing more than one application instance at a time Wednesday, April 2nd, 2008

//check if previous instance of the application is already running

//get the name of our process

string proc = Process.GetCurrentProcess().ProcessName;//Get the list of all processes by that name

Process[] processes = Process.GetProcessesByName(proc);//if there is more than one process

if (processes.Length > 1)

{

MessageBox.Show(”A previous instance of the application is already running”);

return;

}

Linq with Example in .NET 3.5

Linq with Example in .NET 3.5 Tuesday, April 1st, 2008

What is Linq ?

LINQ stands for Language-Integrated Query is now available as a integral part of Visual Studio.
LINQ has a great power of querying on any source of data, data source could be the collections of objects, database or XML files.We can easily retrieve data from any object that implements the IEnumerable interface.

Microsoft basically divides LINQ into three areas and that are give below.

1.LINQ to Object {Queries performed against the in-memory data}
2.LINQ to ADO.Net
= LINQ to SQL
= LINQ to DataSet
= LINQ to Entities
3.LINQ to XML

Linq Sample - Where
——————–

public void Linqsample()
{

int[] numbers = {1,3,2,5,4,7,6,9,8,0};
var findlow = from n in numbers where n

Validating a DropDownList in C# Asp.Net

Validating a DropDownList in C# Asp.Net Wednesday, March 26th, 2008

Use RequiredFieldValidator and set the initial value to the default starting item in the list.         
<td>
        <asp:DropDownList ID=”ctype” runat=”server”>
        <asp:ListItem>Select Credit Card Type</asp:ListItem>
            <asp:ListItem>Visa</asp:ListItem>
            <asp:ListItem>Amex</asp:ListItem>
            <asp:ListItem>MasterCard</asp:ListItem>
            <asp:ListItem>Discover</asp:ListItem>
        </asp:DropDownList>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ runat=”server” ErrorMessage=”Please Select Card Type” ControlToValidate=”ctype” InitialValue=”Select Credit Card Type”>
</asp:RequiredFieldValidator>
</td> 


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.