Error when Querying DB through VB.net

IErrorInfo.GetDescription failed with E_FAIL(0x80004005).

Page 1 of 1

10 Replies - 661 Views - Last Post: 11 February 2009 - 09:03 AM Rate Topic: -----

#1 fatbunny  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 33
  • Joined: 09-February 09

Error when Querying DB through VB.net

Posted 10 February 2009 - 08:44 AM

IErrorInfo.GetDescription failed with E_FAIL(0x80004005).

I get this error when trying to send a query to a database. Its an access 2000 DB. Google suggests the error indicates that I am using a vb keyword as a field name or table name. I have checked with these here and can't see anything that matches.
http://msdn.microsof...19t(VS.71).aspx

The query goes something like this

Select tablename.Field1, tablename.Field1, tablename.Field4, tablename.Field6, tablename.Field1 from tablename
but its quite large

I am using vb.net 2008 express edition.

Is there another list of keywords I missing?

Is This A Good Question/Topic? 0
  • +

Replies To: Error when Querying DB through VB.net

#2 dklingman  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: Error when Querying DB through VB.net

Posted 10 February 2009 - 08:59 AM

lets see some other code for one. two is this statement wrap in double quotes? the other thing is make sure that a the field name isn't a key word in the access database. to avoid that place the fieldname in brackets meaning
"Select tablename.[Field1] from tablename"


Was This Post Helpful? 0
  • +
  • -

#3 fatbunny  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 33
  • Joined: 09-February 09

Re: Error when Querying DB through VB.net

Posted 10 February 2009 - 09:02 AM

ok adding and removing fields through trial and error left me with 3 field name culprits.

zone
dmc
indx

if I remove these it works. The problem is I need these in the query. I tried putting one in, in [] it still doesn't work (a google suggestion) like

Select [zone] from tablename


Any Ideas?
Was This Post Helpful? 0
  • +
  • -

#4 dklingman  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: Error when Querying DB through VB.net

Posted 10 February 2009 - 09:07 AM

what does the rest of your code look like or is this within access itself?
Was This Post Helpful? 0
  • +
  • -

#5 fatbunny  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 33
  • Joined: 09-February 09

Re: Error when Querying DB through VB.net

Posted 10 February 2009 - 10:25 AM

View Postdklingman, on 10 Feb, 2009 - 08:07 AM, said:

what does the rest of your code look like or is this within access itself?


Thanks Derek, that worked but now im getting
"No value given for one or more required parameters."

here is my attempt at code,


'get db1 & db2 site name and numbers
		conDB1.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =C:\DB1\test\phonemas.mdb"
		conDB1.Open()
		strSQL = "Select Site.site_number, site.name from site"
		DB1da = New OleDb.OleDbDataAdapter(strSQL, conDB1)
		DB1da.Fill(DB1ds, "site1info")
		conDB2.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =C:\DB2\test\phonemas.mdb"
		conDB2.Open()
		strSQL = "Select Site.site_number, site.name from site"
		DB2da = New OleDb.OleDbDataAdapter(strSQL, conDB2)
		DB2da.Fill(DB2ds, "site2info")

 ' load site2info in to string array tbc

		DB1da.Dispose()
		DB1ds.Clear()

strSQL = "SELECT template.UserIdentifierID, template.name, template.type, template.cust, template.des, template.[zone], template.dig, template.fdn, template.tgar, template.ncos, template.sgrp, template.sarg, template.ars, template.coms, template.rnpg, template.sci, template.rco, template.ssu, template.scu, template.scc, template.lnrs, template.scpw, template.xlst, template.sflt, template.cls, template.hunt, template.eht, template.efd, template.arto, template.afd, template.ahnt, template.aeht, template.aefd, template.lhk, template.ten, template.ohid, template.fsvc, template.lpk, template.plev, template.fcar, template.ldn, template.spid, template.pri, template.aom, template.dba, template.aday, template.ahol, template.dndr, template.ast, template.iapg, template.[dmc] template.[indx] FROM template"

		DB1da = New OleDb.OleDbDataAdapter(strSQL, conDB1)
		DB1da.Fill(DB1ds, "templates1")

		'Upload templates to DB2
		DB2da = New OleDb.OleDbDataAdapter(strSQL, conDB2)
		DB2da.Fill(DB2ds, "Templates")
		DB2ds = DB1ds
		DB2da.Update(DB2ds, "Templates")



Was This Post Helpful? 0
  • +
  • -

#6 General Adamus  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 110
  • Joined: 05-February 09

Re: Error when Querying DB through VB.net

Posted 10 February 2009 - 10:46 AM

View Postfatbunny, on 10 Feb, 2009 - 08:02 AM, said:

ok adding and removing fields through trial and error left me with 3 field name culprits.

zone
dmc
indx

if I remove these it works. The problem is I need these in the query. I tried putting one in, in [] it still doesn't work (a google suggestion) like

Select [zone] from tablename


Any Ideas?


Do the fields exist in the table?
If you answer yes...Are you sure?
If you answer yes...Did you look?
If you answer yest...Did you really look?

Adamus
Was This Post Helpful? 0
  • +
  • -

#7 dklingman  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: Error when Querying DB through VB.net

Posted 10 February 2009 - 11:12 AM

ok since the last guy that posted was completely useless.

check and make sure that you dataadapter has an update and/or insert commands. if not you will need either create the command yourself and add them to the adapter or you could you the commandbuilder to do it.

based on the error you're getting i'm guessing it's because something isn't right with insert and/or update commands.

personally i do not like using the command builder although its quick i feel i lose some control over what i want to do... again only my own opinion.
Was This Post Helpful? 0
  • +
  • -

#8 General Adamus  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 110
  • Joined: 05-February 09

Re: Error when Querying DB through VB.net

Posted 10 February 2009 - 03:34 PM

View Postdklingman, on 10 Feb, 2009 - 10:12 AM, said:

ok since the last guy that posted was completely useless.

check and make sure that you dataadapter has an update and/or insert commands. if not you will need either create the command yourself and add them to the adapter or you could you the commandbuilder to do it.

based on the error you're getting i'm guessing it's because something isn't right with insert and/or update commands.

personally i do not like using the command builder although its quick i feel i lose some control over what i want to do... again only my own opinion.

Yes you're probably right. Even though the OP has already stated that he's narrowed the culprits down to 3 fields and everything runs fine without them...it's probably an adapter issue.

Good thinking

Adamus
Was This Post Helpful? 0
  • +
  • -

#9 dklingman  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: Error when Querying DB through VB.net

Posted 10 February 2009 - 07:15 PM

View Postfatbunny, on 10 Feb, 2009 - 12:25 PM, said:

View Postdklingman, on 10 Feb, 2009 - 08:07 AM, said:

what does the rest of your code look like or is this within access itself?


Thanks Derek, that worked but now im getting
"No value given for one or more required parameters."

here is my attempt at code,


'get db1 & db2 site name and numbers
		conDB1.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =C:\DB1\test\phonemas.mdb"
		conDB1.Open()
		strSQL = "Select Site.site_number, site.name from site"
		DB1da = New OleDb.OleDbDataAdapter(strSQL, conDB1)
		DB1da.Fill(DB1ds, "site1info")
		conDB2.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =C:\DB2\test\phonemas.mdb"
		conDB2.Open()
		strSQL = "Select Site.site_number, site.name from site"
		DB2da = New OleDb.OleDbDataAdapter(strSQL, conDB2)
		DB2da.Fill(DB2ds, "site2info")

 ' load site2info in to string array tbc

		DB1da.Dispose()
		DB1ds.Clear()

strSQL = "SELECT template.UserIdentifierID, template.name, template.type, template.cust, template.des, template.[zone], template.dig, template.fdn, template.tgar, template.ncos, template.sgrp, template.sarg, template.ars, template.coms, template.rnpg, template.sci, template.rco, template.ssu, template.scu, template.scc, template.lnrs, template.scpw, template.xlst, template.sflt, template.cls, template.hunt, template.eht, template.efd, template.arto, template.afd, template.ahnt, template.aeht, template.aefd, template.lhk, template.ten, template.ohid, template.fsvc, template.lpk, template.plev, template.fcar, template.ldn, template.spid, template.pri, template.aom, template.dba, template.aday, template.ahol, template.dndr, template.ast, template.iapg, template.[dmc] template.[indx] FROM template"

		DB1da = New OleDb.OleDbDataAdapter(strSQL, conDB1)
		DB1da.Fill(DB1ds, "templates1")

		'Upload templates to DB2
		DB2da = New OleDb.OleDbDataAdapter(strSQL, conDB2)
		DB2da.Fill(DB2ds, "Templates")
		DB2ds = DB1ds
		DB2da.Update(DB2ds, "Templates")





based on that error it normally comes from when something isn't defined correctly in a command or you are missing parameters. it's not that you are missing fields, but because you have a syntax error with you sql statement. if you look the fields right before the FROM you have it written as

template.[dmc] template.[indx]

notice that you don't have a comma between the fields. it should be

template.[dmc], template.[indx]

if you are selecting all the fields in the table just do a
select * from template

this will avoid mistakes like this. if you need to do something like this a better way would be to break it down into more then one line. when i write a statement that has this many fields for a sql statement i tend to use a StringBuilder object and use the Append method of the StringBuilder object.

This post has been edited by dklingman: 10 February 2009 - 07:20 PM

Was This Post Helpful? 1
  • +
  • -

#10 fatbunny  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 33
  • Joined: 09-February 09

Re: Error when Querying DB through VB.net

Posted 11 February 2009 - 08:56 AM

Thanks for that. I did notice that missing comma and corrected it.
The statement works fine if I run the query in access, I always use it to double check when I run in to problems.
The "No value given for one or more required parameters" error is still there, at the exact same point

DB1da.Fill(DB1ds, "templates1")


but its different to the last one so I will do some research on this one now.

I would to a "Select * from template" but I need to columns in a specific order (different to the current order) and this is the only
I know of rearranging them.
Was This Post Helpful? 0
  • +
  • -

#11 fatbunny  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 33
  • Joined: 09-February 09

Re: Error when Querying DB through VB.net

Posted 11 February 2009 - 09:03 AM

Ok my bad, I had two different version of the database (not my on, trying to work on someone else's database) so I wasn't aware that there was two different ones. When I tested, I tested on the latter one with the two new DB fields dmc and indx.
There weren't in the old one that I had VB.net using.

Thanks for the help!!!!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1