Installing Intel X3100 Graphics Driver on Toshiba Sattellite M200 Laptops having WS2003 as Operating Sytem

September 29, 2008 at 12:03 pm (DevSoft Tweaks)

 

Those of you who are having trouble in installing X3100 Graphics Driver on Toshiba Satellite M200 and similar laptops in that series, the problem is that the driver that toshiba people have on their site is old version and it works only on Windows XPSP2 and later OS,it does not work on Windows Server 2003 OS.

So the solution is just download the Graphics Driver for Windows XP for Dell Inspiron 1525.

These dell people have latest  driver and it install very smoothly on Windows Server 2003.

If this also is not working for you than you can add setup.exe in the application verifier and do the proceeding as given in this post.

http://smallworkarounds.blogspot.com/2008/09/installing-photoshop-cs3-on-windows.html

Permalink Leave a Comment

When to use using and when to use try catch to do the cleaning

September 29, 2008 at 12:03 pm (C#)

  1. We have two ways to clean up utilized resources in C# either we can use try..catch..finally statements series or we can use the using statement in C#
  2. The thing is that resources should be released and cleanup must be performed either before exitting the using block or just entering up the finally block.
  3. Use using Statement in C# to release up the resources when the creating type implements the IDisposable interface.
  4. Use try..catch..finally when we need to perform cleanup but not necessarily employ the Dispose Method.

Permalink Leave a Comment

Anonymous Types in C#

September 29, 2008 at 8:48 am (C#, Linq)

  1. Anonymous types in C# are a new concept which shipped with .net framework 3.5
  2. Anonymous types are nothing but it simply states that we dont have to define a type and that type is defined automatically by C# analysing the right hand side.
  3. Anonymous Types are very important in the LINQ word.
  4. Keyword var is used to declare an anonymous type.
  5. They are immutable and thus dont require any property getter or setter methods
  6. They must always be initialized so that the compiler can build the type defination and bind the anonymous type with that , and it is only possible only when we have any thing in the right hand side of an anonymous type thus anonymous types should always be initialized.

//1.Shows Simple anonymous varible declarations and iterating using for loop
var fabonici = new int[]{1,1,2,3,5,8,13,21};
for( var i = 0; i<fabonici.Length; i++)
{
    Console.WriteLine(fabonici[i]);
}

//2.Show Simple anonymous variable declarations and iterating using foreach loop
var fabonici =  new int[]{1,1,2,3,5,8,13,21};
foreach (var fibo in fabonici)
Console.WriteLine(fibo);

//3.Linq query used as iterand in foreach statement.
var fabonici = new int[]{1,1,2,3,5,8,13,21};
foreach (var fibo in
         from f in fabonici
         where f%3 == 0
         select f)
Console.WriteLine(fibo);

Permalink Leave a Comment

Custom functions recieving StoredProcedure Name and Command Parameters to reduce code duplicacy, by redundant open() and close() sql Connection calls.

September 29, 2008 at 8:34 am (C#, SqlServer)

 

Here is the sample code for 3 static functions to be written in your SqlHelper or DAL or any other Data Related class.

public static void DBExecuteNonQuery(string storedProcedure,SqlCommand command)
   {       
       using(SqlConnection connection = new SqlConnection(ConnectionString))
       {
           connection.Open();
           command.CommandText = storedProcedure;
           command.Connection = connection;
           command.CommandType = CommandType.StoredProcedure;          
           command.ExecuteNonQuery();
       }
   }

 

1.DBExecuteNonQuery is receiving two parameters one is the name of the stored procedure and other is the prebuild  command having all the parameter names and values, later in the function we open the connection and provide the CommandText as the recieved stored Procedure name, command connection as connection,command type as commandtype.storedprocedure and then we execute the command.ExeuteNonQuery statement.

2.Similarly we do things in other functions the only difference is of the return type and the execute function.

   public static Int32 DBExecuteScalar(string storedProcedure, SqlCommand command)
   {
       Int32 value = 0;
       using (SqlConnection connection = new SqlConnection(ConnectionString))
       {
           connection.Open();
           command.CommandText = storedProcedure;
           command.Connection = connection;
           command.CommandType = CommandType.StoredProcedure;
           value = (Int32)command.ExecuteScalar();
       }
       return value;
   }

3.DBExecuteScalar takes the same arguments but returns an Int32 type value and Executes the stored procedure using command.ExecuteScalar() function

 
   public static DataSet DBExecuteReader(string storedProcedure, SqlCommand command)
   {
       SqlDataReader reader = null;
       using (SqlConnection connection = new SqlConnection(ConnectionString))
       {
           connection.Open();
           command.CommandText = storedProcedure;
           command.Connection = connection;
           command.CommandType = CommandType.StoredProcedure;
           reader = command.ExecuteReader();  

//Here we can write any custom code to convert the reader to a dataset because when the     connection will be closed if we return reader it will complain as it is connected type.

       }
      return dataSet;
   }

4.DBExecuteReader also takes similar arguments but return a SqlReader which you can iterate through to get the desired output.

5.These functions might come handy when you are using multiple opening and closing connection calls it might not help in performance but it make the code look clean and reduce the duplicacy.

6.ConnectionString used above is a static property in the SqlHelper Class which can be used to retreive the connection string from web.config in web applications and app.config in Winforms applications.

public static string ConnectionString

{

get{return System.Configuration.ConfiguraitonManager.ConnectionStrings["connectionsstringname"].ConnectionString;}

}

7.Now we can directly use these functions as following code snippet shows:-

SqlCommand command = new SqlCommand();
        command.Parameters.Add("@firstName", SqlDbType.VarChar).Value = person.FirstName;
        command.Parameters.Add("@middleName", SqlDbType.VarChar).Value = person.MiddleName;
        command.Parameters.Add("@lastName", SqlDbType.VarChar).Value = person.LastName;
        command.Parameters.Add("@gender", SqlDbType.Bit).Value = person.Gender;
        command.Parameters.Add("@email", SqlDbType.VarChar).Value = person.Email;
        command.Parameters.Add("@address", SqlDbType.VarChar).Value = person.Address;
        command.Parameters.Add("@qualification", SqlDbType.VarChar).Value = person.Qualification;
        command.Parameters.Add("@password", SqlDbType.VarChar).Value = person.Password;

        SqlHelper.DBExecuteNonQuery("usp_InsertPerson", command);       

If you want more modularity and donot want to pass command from your business logic  layer and want to make this command only in your Data Access Layer than you can add the following methods to your SqlHelper.cs file

public static DataSet ConvertToSqlCommand(string storedProcedure,SortedList values)

        {

            SqlCommand command = new SqlCommand();

            foreach (KeyValuePair  value in values)

            {

                Type type = value.Value.GetType();

                SqlDbType sqlDBType = ConverToSqlDBType(type);

                command.Parameters.Add(value.Key, sqlDBType).Value = value.Value;

                //SqlDbType value.Value.GetType()

            }

            DataSet dataSet = DBExecuteReader(storedProcedure, command);

            return dataSet;           

        }

        public static void ConvertToSqlCommandForNonQuery(string storedProcedure, SortedList values)

        {

            SqlCommand command = new SqlCommand();

            foreach (KeyValuePair value in values)

            {

                Type type = value.Value.GetType();

                SqlDbType sqlDBType = ConverToSqlDBType(type);

                command.Parameters.Add(value.Key, sqlDBType).Value = value.Value;

            }

            DBExecuteNonQuery(storedProcedure, command);

        }

These two overloaded methods take storedprocedure name and sortedlist ie key value pair as parameters and convert them to sqlcommands and execute the related DBExecute……() function and return the output.

The problem with this approach is that we have to convert System.Type to System.Data.Type ie SqlDBType which is an enumeration thus a probable limitation is that it cannot understand which string is to be converted to char,varchar and nvarchar for rest it works fine.Given below is the method which achieves this you can add another entries if you want.

        public static SqlDbType ConverToSqlDBType(Type systemType)

        {

            if (systemType.Name == "Int32")

                return SqlDbType.Int;

            else if (systemType.Name == "String")

                return SqlDbType.VarChar;

            else if (systemType.Name == "DateTime")

                return SqlDbType.DateTime;

            else

                return SqlDbType.VarChar;

        }

Uploaded Below is the SqlHelper.cs file which achieves the desired result.
http://cid-d3498dea37dde9b0.skydrive.live.com/self.aspx/Files/SqlHelper.cs

Permalink Leave a Comment

How to make a function accepting variable arguments of same type in C#

September 23, 2008 at 8:32 am (C#)

Here is a simple way by which we can declare a function in C# which accepts variable arguments of a particular type.

We have a keyword params in C# which we can use in the parameters in a function.

 public class Util
{public static List<int> AddIntegersToList(params int[] integerList){   List<int> numbers = new List<int>();   foreach (int item in integerList) {  numbers.Add(item); }
return numbers;}

Now this will accept an array of integers and thus the no of integers which can be passed here is not fixed and hence it fullfills our requirement of a function which can receive variable no of arguments of a single type.

Now for the above function we can use

List<int> listOfIntegers = Util.AddIntegersToList(2, 8, 9, 56, 77);

We can pass here any no of integers.

Permalink Leave a Comment

Boxing And Unboxing in C#

September 18, 2008 at 4:01 pm (C#)

1. Boxing is when we convert a value type into reference type,when we are boxing we are creating reference variables which point to a new copy on the heap.

2. Unboxing is when we convert a reference type to a value type.

3. Best example of boxing and unboxing can be while we store integer variable which is a value type in a ArrayList which is a reference type.

4. And when we retrieve the value stored in ArrayList to an integer then we change a reference type to value type ie we do unboxing.

ArrayList myArrayList = new ArrayList();Int n = 7;myArrayList.Add(n);//Boxing of nn = (int)myArrayList[0];//Unboxing of myArrayList[0]  

Permalink Leave a Comment

Two uses of using keyword in C#

September 18, 2008 at 3:22 pm (C#)

There are two uses of using keyword in C#

i)Using as Directive in C# can be used for importing namespaces to your classes.

ii)Another most useful advantage is it can be used in codeblocks what is does is it calls the Dispose() method automatically to release the resources and also automatically implements the try catch blocks for you.Here it is called a using statement.So the advantage is that we dont have to explicitly write a try-catch block and our code looks tidy.

Permalink Leave a Comment

Installing Photoshop CS3 on Windows Server 2003 Systems

September 17, 2008 at 10:44 am (DevSoft Tweaks)

Hi yesterday i was trying to install Photoshop CS3 on a system having Windows Server 2003 installed.

But it gives me an error saying that you need a OS equivalent to Windows XP SP2 or greater or Windows Vista.

So i found a workaroud which i would like to share with you.

Just download a utility from Microsoft called Application Verifier its a small but very benificial utility.Link is http://www.microsoft.com/downloads/details.aspx?familyid=bd02c19c-1250-433c-8c1b-2619bd93b3a2&displaylang=en

1.Run the Application Verifier and open the setup.exe file for photoshop cs3 and go to the compatibility tree view column.

2.Go to HighVersionLie and right click it to get properties.

appverifier

3.Now suppose if you want to any program assume that you are using Windows XP SP2 then enter like below figure in the boxes that follow

properties

4.Click OK And then Save

5.It will then ask you for the debugger to be attached do not attach any debugger and click save .

6.Now if you try installing it will be installed with no problems.

Permalink Leave a Comment

Dotnet and C# Begginner Series Part-1

September 17, 2008 at 9:44 am (.Net Framework Essentials)

Important Learning

1. Common Language Specification is a part of Common Type Systems which in turn is a part of Common Language Runtime.

2. We can take any language and if we can have or make a .net aware compiler for that language then we are done ie we can start writing code in that language and it will run on .net framework installed machines.We needn’t worry about the platform now, as .net will take care for that.

3. Single file assemblies and multifile assemblies.The difference is that we can have all our referenced code in a single assembly it is beneficial when we have only a small application and our client needs to download only a small part ie only that assembly and that’s done.But if we are making a big application in which there are thousands of small application so we neednot place everything into a single assembly whereas we can place things in different assemblies the benefit is that if our clients need some network related stuff so he can download that assembly and start working he needn’t download the whole application as such so it reduces the download time and make process faster.

4. What actually happens for those people who don’t know .net and are programmers in other languages is that first we write code in any .net language let’s be concerned now with only the languages which ship with .net.Now all these languages such as VB.Net ,C#,C++/CLI,J#,JScipt.net follow Common Type Specification and Common Language System.So if you write Dim myInt as Integer in vb.net and someone else write int myInt in C# it will be compiled by vbc.exe and csc.exe to same thing ie Sys.Int32 which is the example of Common Type System and thus it means they are same at the Intermidiate Language Level

5. What these compilers do is they generate Intermediate Language which is not instruction set specific ie which is not platform specific ie it does not contain any platform specific information which earlier COM assemblies ie .dll and .exe used to do.

6. One important point which comes here is that the assemblies generated by .net are different then the dll and exes generated by the COM components.

7. COM used to generate platform specific dlls or exe’s but .net generates dll’s and exe’s which contain metadata and CIL .

8. This metadata consists of manifest files which contains information about the assembly like versioning,culture information,and list of externally referenced assemblies which are required to run that assembly.

9. CIL or Common Intermidiate Language or MSIL or IL whatever you can call it is in some sense same like Java Bytecode ie they both are not platform specific.

10. ByteCode in Java contains information which Java Virtual Machine understands and then generate or run the required operating system calls and resource allocation based on operating system and the architecture.For example if I have written in my Java Code that allocate me 2MB of ram.Now the bytecode will ask the virtual machine to allocate the resource now it’s the duty of virtual machine to do the heavy lifting and make system calls or any other thing to allocate the resource.

11. So lets consider different OS only not different architectures os let say x86 architecture,and Windows platform ,now here for allocating RAM the system call could be alloc_mem(amount) so it’s the work of Virtual machine to make this call.

12. On x86 and Linux this system call might change and we could have mem_alloc(totalamount) so again it’s the work of JVM specific to x86 Linux to make that call and execute the code.

13. So a question can be why not have a single JVM which could do all this for all platforms and architecture.In theory we can have single JVM also which can first perform a check for architecture and then for the operating system and then execute in a specific way,but its not necessary because such JVM will be huge in size and too complex and slow and also as it has bigger size it would be a waste of time and network resources for the client to download that.

14. If the client doesnot need any support for Windows , Solaris,Mac,Novell and etc.. he only needs it for linux then why should he download all crap.Thus I think they have different JVM’s there might be other limitations when we come to architecture.

15. So this was the story of JVM similar thing happens here in .net also when we get CIL now when we want to run and execute this code we need a Just In Time compiler which will compile this to the platform specific information.

16. So there are two compilations going on one when the code was compiled from its base language to the IL and another compilation is when the IL code is executed.

17. This second compilation is also managed by .net framework it searches for the platform and make the required calls and allocate the required resources just like we have seen in the concept of JVM

18. For .net languages we have support of Base Class Libraries which are simply collections of pre-defined classes which we can use as starting point and then implement bigger things over them.

19. This BCL is divided into many parts grouped under various meaningful namespaces.

Permalink Leave a Comment

How to change the product key of any windows operating system if you have already installed a key.

September 16, 2008 at 12:09 pm (DevSoft Tweaks)

You can do it with WinKey Finder with ease.Although you can do it manually by editing some registry key but i think that its not a convinient method.

So here is the link where you can donwload this tool and play with it.

http://files6.majorgeeks.com/files/f06048518ff8de2035363e00710c6a1d/covertops/WinKeyFinder173_RC2.zip

Permalink Leave a Comment

Next page »