0

Hey Guys,

I am now loosing my cool over this problem.
let me paste my code an then i'll explain my problem.

Here's my code :

if (rn < ds1.Tables["Company"].Rows.Count-1)
                {
                    rn = rn + 1;
                    textBox1.Text = ds1.Tables["Company"].Rows[rn].ItemArray[0].ToString();

                    SqlDataAdapter da1 = new SqlDataAdapter("Select C_ID from Company where C_NAME ='Germany'", con2);

                    da1.Fill(ds1, "Company");

Here, I have a textbox that should show the id of company that is selected by user from combo box. But somehow it keeps on nudging me error : Object reference not set to instance of an object. I tried all possible ways but couldn't find a way around.
Can anybody of you suggest anything?


thank you
Ajinkya

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Mitja Bonca
0

How will dataSet show some value from it, if its empty. YOu have to retrieve the value from dataSet to textBox, after its being populated. So put the code from 4th line, bellow the line where you do the filling ("Fill()" method).

If this is not it, tell more about the problem, and tell us exactly is comes to that error.
Mitja

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.