0

I am using ADODB Connection in C#.

Following is from VB code I want it like in C#.

    empcode.Text = IIf(IsDBNull(mRS("Accode").Value), "", mRS("Accode").Value)

Like above code, I want to retrieve data to a textbox in C#.

Thanks & Regards.

1 Answer 1

1

You should really include more context to your question, but here goes:

empcode.Text = mRS.Fields["Accode"].Value == System.DBNull.Value ? string.Empty : mRS.Fields["Accode"].Value.ToString();
Sign up to request clarification or add additional context in comments.

5 Comments

Hello, Thanks for your reply. I had tried above code but it is giving error as "Cannot apply indexing with [] to an expression type 'Recordsrt'".
And mRS is Recordset.
Updated the answer. Please update your question with your full code.
txtdef.Text = mRS.Fields["Ask1"].Value == DBNull.Value ? string.Empty : mRS.Fields["Ask1"].Value.ToString();
That's exactly what my answer said (on a different field as per your question)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.