468,251 Members | 1,381 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,251 developers. It's quick & easy.

"Object reference not set to an instance of an object.".....error

hi,
i wrote the following code to get a specific data row from the data set.but it generates the
"Object reference not set to an instance of an object.".....error
private void showClientListForUser()
{
string[] fkeys = new string[2];

fkeys[0] = txtUserName.Text;
fkeys[1] = txtUserCompanyNumber.Text;

DataSet ds = new DataSet();
DataRow dr = null;

for (int i = 0; i < dsMain.Tables["UserClient"].Rows.Count; i++)
{
dr[i] = dsMain.Tables["UserClient"].Select("UserID="+"'"+fkeys[0]+"'"+ "and CompNo= " + fkeys[1]);------//this line throws the error i told.

// dr = ds.Tables[0].Rows[i];
lvwClientsForUser.Items.Add(Convert.ToString(dr["CompNo"]));
lvwClientsForUser.Items[i].SubItems.Add(Convert.ToString(dr["ClientNo"]));
lvwClientsForUser.Items[i].SubItems.Add(Convert.ToString(dr["CNAME"]));
}
}
if anyone can help me to correct this error?
Sep 27 '07 #1
0 1023

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by My Pet Programmer | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.