2 Replies - 1079 Views - Last Post: 27 December 2011 - 12:14 PM Rate Topic: -----

#1 webwired  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 339
  • Joined: 26-August 07

SQLCommand.Parameters C# Syntax Issue

Posted 27 December 2011 - 12:05 PM

Hello everyone...

I was borrowing a snippet of code from one of my VB .NET projects and for the life of me I can't figure out how to make it work for C#...

Dim totalBillableTime As Decimal = Decimal.Parse(cmd.Parameters("@TotalBillableTime").Value.ToString())
Return totalBillableTime



I need a string returned instead of a decimal, I tried this, and a few other variations, to no success... I get this error, "Non-invocable member 'System.Data.SqlClient.SqlCommand.Parameters' cannot be used like a method."
string assetTypePrefix = cmd.Parameters("@AssetTypePrefix").Value;



Is This A Good Question/Topic? 0
  • +

Replies To: SQLCommand.Parameters C# Syntax Issue

#2 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 385
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: SQLCommand.Parameters C# Syntax Issue

Posted 27 December 2011 - 12:11 PM

In C#, if you want to refer to a index, you have to use square brackets
string assetTypePrefix = cmd.Parameters["@AssetTypePrefix"].Value.ToString()


Was This Post Helpful? 1
  • +
  • -

#3 webwired  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 339
  • Joined: 26-August 07

Re: SQLCommand.Parameters C# Syntax Issue

Posted 27 December 2011 - 12:14 PM

View PostIonut, on 27 December 2011 - 01:11 PM, said:

In C#, if you want to refer to a index, you have to use square brackets
string assetTypePrefix = cmd.Parameters["@AssetTypePrefix"].Value.ToString()



Awesome, thank you for that info, it will come much in handy as I borrow code from my VB to use in and learn C#
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1