Skip to content

Help with converting vbcode to c sharp.

Justin McKay

Asked Feb 19, 2007, 6:19 PM EST1 answer
Share
LinkedInX
Greetings, I have just started learning the C Sharp language, based on what i already know from vb. im currently converting my website to c sharp, just to get a feel for the language, how ever im stuck. the following vbcode, when converted to c sharp, does not recognise _param as a defined struct.. (eg: not giving any of the properties.) 'VB Code: Dim _param As SqlParameter = hashEnum.Value objCommand.Parameters.Add(_param.ParameterName, _param.ParameterDataType).Value = _param.ParameterValue //C Sharp Code SqlParameter _param = hashEnum.Value; objCommand.Parameters.Add(_param.ParameterName, _param.ParameterDataType).Value = _param.ParameterValue; when i go to type _param. i get no intellisense about the properties... can anyone help, Thanks, Justin

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    I think you've fallen into the age old VB to C# pitfall.

    Instead of 'Dim _param As SqlParameter', do 'SqlParameter _param = new SqlParameter()'.

    You may also need to add in a couple of using statements:

    using System.Data.SqlClient;

    and possibly (although I doubt it) using System.Data;

    Hope that helps.

    0