Reputation: 39
I am developing a project in C#.I am retrieving data from database to textbox.
In vb following code is used for retrieve data.
empcode.Text = IIf(IsDBNull(mRS("Accode").Value), "", mRS("Accode").Value)
And In C# I am using following code to retrieve data.
empcode.Text = mRS["Accode"] == System.DBNull.Value ? string.Empty : mRS["Accode"].ToString();
But in C# code it is giving following error in "mRS["Accode"]".
"Cannot apply indexing with [] to an expression type 'Recordset'".
Where mRS is Recordset.
Thanks & Regards
Upvotes: 0
Views: 193
Reputation: 26
In VB the expression mRS("Accode")
is expanded to mRS.Fieldset("Accode")
automatically. So you should write mRS.Fieldset["Accode"]
in C#.
Upvotes: 1