Wednesday, May 27, 2009

Few moments with Dotnetspider : DNS-MVM award

In continuation on my award of MVM from dotnetspider.com, DNS published my interview on this award.

In this interview I have shared my views with Raghav on my this achievement.

The tenure of interview is around 60-minutes, I really enjoyed with Raghav.

Here is the link of my interview : http://www.dotnetspider.com/forum/206923-Few-moments-with-Meetu-Choudhary-DotNetSpider-MVM.aspx

Sunday, May 24, 2009

Few moments with Dotnetspider : DNS-MVM award

In continuation on my award of MVM from dotnetspider.com, DNS published my interview on this award.

In this interview I have shared my views with Raghav on my this achievement.

The tenure of interview is around 60-minutes, I really enjoyed with Raghav.

Here is the link of my interview : http://www.dotnetspider.com/forum/206904-Few-moments-with-Gaurav-Arora-DotNetSpider-MVM.aspx

Sunday, May 3, 2009

A great eve in Hyderabad - Microsoft TechEd2009

Lets cheers, its a good news for all Microsoft lovers.
Microsoft TechEd2009 will be conducting in Hyderabad from May13 to May15.

Main attention of the eve is Steven A. Ballmer,CEO Microsoft. This is the greatest and biggest eve in India and expecting to see a huge crowd from developer community.

To grab more details please visit : Microsoft TechEd2009.

Thursday, April 30, 2009

Using enum Search Database

Using enum Search Database

This example demonstrates the use of enum.
How this enum is used to set the way to fecth data from the database

Declaring enum



/// this enum will define in which way the search should be made
/// all stats that the parameter should exactly match
/// start states that the vlaue passed should be serched for any value starting with
/// End states that the vlaue passed should be serched for any value ending with
/// Middle states that the vlaue passed should be serched for any value which conatins these charates any where
///

public enum SearchDirection
{
All=0,
Start=1,
End=2,
Middle=3
}


Declaring and Defining the function



///
/// Checks the Field Value whether exist in database or not
///

/// Value to check for
/// Value to check in which field
/// Value to Check in which Table
/// Specifies the search direction
///
public Int32 CheckFieldValue(String fldValue, String fldName,String TblName,SearchDirection SearchDir)
{

String strquery = "";
String str=Enum.GetName(typeof(SearchDirection),SearchDir);
if(((Int32)Enum.Parse(typeof(SearchDirection),str))==0)
{
strquery = "select * from " + TblName + " where " + fldName + " ='" + fldValue + "'";
}
else if (((Int32)Enum.Parse(typeof(SearchDirection), str)) == 1)
{
strquery = "select * from " + TblName + " where " + fldName + " like'" + fldValue + "%'";
}
else if (((Int32)Enum.Parse(typeof(SearchDirection), str)) == 2)
{
strquery = "select * from " + TblName + " where " + fldName + " like'%" + fldValue + "'";
}
else if (((Int32)Enum.Parse(typeof(SearchDirection), str)) == 3)
{
strquery = "select * from " + TblName + " where " + fldName + " like'%" + fldValue + "%'";
}

SqlConnection DBConnection = new SqlConnection();
SqlCommand DBCommand = new SqlCommand();
if (DBConnection.State == ConnectionState.Closed)
{
DBConnection.ConnectionString = "yourConnectionString";
DBConnection.Open();
}
DBCommand.Connection = DBConnection;
DBCommand.CommandText = strquery;
Int32 i=DBCommand.ExecuteNonQuery();
DBConnection.Close();
return i;

}



++
Thanks and Regards
Meetu Choudhary
http://msdotnetmentor.com

Subscribe via email

Enter your email address:

Delivered by FeedBurner

MSDotnetMentor

MSDotnetMentor My Website http://msdotnetmentor.com