Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

When I try to fill a dataset table using the SELECT statement listed below, I get the following error:

 

Unspecified error: E_FAIL(0x80004005)

 

Here is the relevant code:

 

string strSelectA = null;
strSelectA = "SELECT ComputerName, Domain FROM REF_CSDComputers " +
  "WHERE (Billable='" + true.ToString() + "')";
OleDbDataAdapter assetAdapter = new OleDbDataAdapter(strSelectA, master);

try
{
  assetAdapter.Fill(ds1, "lookup");
}
finally
{
  master.Close();
}

 

Obviously, the error occurs when I attempt to use the Fill method of the assetAdapter.

 

The dataset ds1 definitely exists, and in fact, there is a line of code calling the Fill method of another DataAdapter just above the assetAdapter.

 

Any help is greatly appreciated.

Never ascribe to malice that which is adequately explained by incompetence. - Napoleon Bonaparte
  • *Experts*
Posted

in fact, there is a line of code calling the Fill method of another DataAdapter just above the assetAdapter.

 

If the line above is coded the same way, then you're passing a Closed connection to the second DataAdapter. The Finally code always runs, which is probably closing the Connection after the first use.

 

-nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

Database Connection is OK...

 

I double-checked on your suggestion. The Fill method checks the status of the related connection object and automatically Opens that object if it is closed.

 

I've also tried playing with the "Billabe=" portion of the SELECT statement, including using Yes, True, and 1.

 

Thanks for the feedback.

Never ascribe to malice that which is adequately explained by incompetence. - Napoleon Bonaparte
Posted

SOLUTION...

 

And the answer is...

 

Place '[' and ']' brackets around the word Domain in the SELECT statement.

Never ascribe to malice that which is adequately explained by incompetence. - Napoleon Bonaparte

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...