OK I'm completely new to C# and .NET ... I'm not a developer! My only previous developerish experience is VBScript.
I wrote a script in PowerShell (which I've not done much in before either) to query a SQL database and display results. I've fiddled with ADO from VBScript about twice before...
I got my script working. It uses a SqlDataReader to pull records based on a SQL query and then gets individual fields with this line after doing a Read():
$callID = $dataReader.Item("CallID")
I've been trying to convert this all to C# since PowerShell syntax is very similar (this will be my first ever C# program!) If I try and replace the above line with
string callID = dataReader.Item["CallID"];
I get an error before even running anything:
r' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'System.Data.SqlClient.Sql
' could be found (are you missing a using directive or an assembly reference?)"
I've seen an example online where it appears the syntax may need to be:
string callID = (string)dataReader["CallID"];
but I don't understand why this should be, since the SDK shows Item[<string>] as a property of the SqlDataReader object.
What's going on? The SDK makes it look as though it should be easy and indeed from PowerShell it was.
I'm sure there must be a simple explanation. Thanks!