Globalizing Web Community Menu

Home
Mission
Message
Blog
Downloads
Favorite Links
Thanks
Invitation
Coty

     
Login or Register
Information Site

Back To Blog

Archive Links


August 18, 2006


February 25, 2006
February 8, 2006
January 15, 2006
November 16, 2005
October 31, 2005
October 1, 2005
September 20, 2005
September 3, 2005


   

5/1/2008

Visual Basics vs. C Sharp



As I felt that C# is getting more popular than Visual Basics, I decided to write my new code in C#. I assumed that there would be not much difference in essential coding except for the coding format. On the way, I had to learn otherwise. There exists some vital syntax that you can use in Visual Basics but cannot be used in C#.

The 1st example I encountered is this:
When executing Sql Insert Command
myConnection.Open();
myCommand.ExecuteNonQuery();
ReturnValue = myCommand.Parameters["@ReturnValue"].Value;

While there is absolutely no problem with Visual Basics for the last line, C# compiler complains that I am using Parameters (which is a Property) as a Method. Perplexed, I applied the C# convertion program on this line of Visual Basics and got the result as follows:
using Microsoft.VisualBasic;
int ReturnValue
=System.Convert.ToInt32(Conversion.Fix(myCommand.Parameters["@ReturnValue"].Value));

Although this C# line may run on Visual Studio 2000 compiler, Visual Studio 2005 compiler complains that “Conversion” is not defined in this context and refused to compile. I, therefore, had to be content with receiving the "rows affected number” from the ExecuteNonQuery and run a separate method to retrieve the auto-generated ID number for the new insertion. If there is a way to receive the SQL Parameter Output.ReturnValue in C#, please let me know.

Comments: 0    Trackbacks: 0




Write a comment

TrackBack Address:
http://www.timeo.com/TrackBack.aspx?ID=112
   

RSS FEED