Next

All the visitors to this page should have fair understanding  of C#, SQL and ASP.NET. This is to assist you with the templates that can be used in day to day coding. Good luck with your projects!!!!!!!!!!!!!!!!

 

This is a simple Business service written in C#. This service takes to parameters namely username, password and returns username if the username exists already in database.

public string WebLogin(string SignInName,string password) 

 {

   string sql="";

      try  

       {

         SignInName=SignInName.ToUpper();

         sql=string.Format("select count(*) from TBuyerInfo where CBSignInName='{0}' "+ " and CBPassword='{1}'",SignInName,password.ToUpper());

         int rows=(int)mDatabase.SQLQuerySingle(sql);

         if(rows==1) { return SignInName; }

               return null; }

        catch(Exception ex)

         { mDebug.WriteLine("BWebLogin(): SQL - " + sql + ":" + ex.ToString() ); }

            return null;

         }

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

This is a sample code used to search products by title. Here I search products by there title and store the result in ArrayList.I pass the title of the product to the Business Service "SearchByTitle". Observe that the return type is an ArrayList. ArrayList lets u store the products returned by the service SearchByTitle in an array format that can accessed with the index property of arrays.

public ArrayList SearchByTitle(string title)

  {

     ArrayList items=null;

     new ArrayList();

      try

      { items=new ArrayList();

       title = title.Trim();

      string sql = string.Format("select CProductId  from TProductInfo where       CSng(CEndTime-now)>0 and CSng(CStartTime-now)<0 and CProductTitle like '%{0}%'",    title);

       DDatabaseReader reader = mDatabase.SQLQuery(sql);

       if(reader==null)

      { mDebug.WriteLine("SearchByTitle():Reader is NULL"); 

       return items; }

           while(reader.Read()==true)

      {  items.Add(reader[0]);

       }

      reader.Dispose();

      return items;

         }

     catch(Exception ex)

      { mDebug.WriteLine("SearchByTitle():"+ex.ToString() );

         return items;  }

        }

           

 

 

 

Hosted by www.Geocities.ws

1