.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 7th, 2003, 03:46 PM
praxs praxs is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 1 praxs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Probs with reading AccessDB

Hi,

I am trying out some basic DB access using VB.NET and I am encountering unspecified errors.........

Here is the code that I am trying to run:

Sub Page_Load (Sender as Object, E as EventArgs)
Dim strConnection as String ="Provider=Microsoft.Jet.OLEDB.4.0;Data source=C:\Working\Options.mdb"
Dim strSQL as String="SELECT * FROM Names;"

Dim objConnect as new OleDbConnection(strConnection)
Dim objCommand as new OleDbCommand(strSQL, objConnect)
objConnect.Open()

Dim objReader as OleDbDataReader
objReader = objCommand.ExecuteReader()
datagrd.DataSource = objCommand.ExecuteReader()
datagrd.DataBind()

objConnect.Close()

End Sub

This is the error message I am getting.............


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Unspecified error: E_FAIL(0x80004005)

Source Error:
Line 14:
Line 15: Dim objReader as OleDbDataReader
Line 16: objReader = objCommand.ExecuteReader()
Line 17: datagrd.DataSource = objCommand.ExecuteReader()
Line 18: datagrd.DataBind()


Source File: C:\Working\AccessDB.aspx Line: 16

Stack Trace:


[OleDbException (0x80004005): Unspecified error: E_FAIL(0x80004005)]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +154
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +92
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +65
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +112
System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +57
System.Data.OleDb.OleDbCommand.ExecuteReader() +7
ASP.AccessDB_aspx.Page_Load(Object Sender, EventArgs E) in C:\Working\AccessDB.aspx:16
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724


Can anyone please suggest what is wrong with this.........

Thanks & regds
praxs

Reply With Quote
  #2  
Old December 9th, 2003, 12:58 PM
dkode dkode is offline
PHP/PERL/.NET Coder
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Daytona Beach, Florida
Posts: 36 dkode User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 sec
Reputation Power: 8
Send a message via AIM to dkode
i think its because you have a ; at the end of your SQL statement. remove that.

then add in try, catch, finally blocks so that you can actually see the error message that access/vb is kicking back like so:

Code:
Try
    Dim objReader as OleDbDataReader
    objReader = objCommand.ExecuteReader() 
    datagrd.DataSource = objCommand.ExecuteReader() 
    datagrd.DataBind()
Catch ex as OleDbException
    lblError.text = ex.Message
Finally
    objConnect.Close() 

I'm not sure about the catch ex as part, i think there is a different exception for sql string errors.
__________________
"Mankind cannot define memory, yet it defines mankind"

Reply With Quote
  #3  
Old December 16th, 2003, 11:20 AM
RouteSquared RouteSquared is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: London
Posts: 1 RouteSquared User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I found this in the MS .Net SDK [quoted] :

Note Using an Access (Jet) database as a data source for multithreaded applications, such as ASP.NET applications, is not recommended. If you must use Access as a data source for an ASP.NET application, and are unable to use an alternative such as SQL Server or MSDE, be aware that ASP.NET applications connecting to an Access database can encounter connection problems most commonly related to security permissions. For help troubleshooting connection problems using ASP.NET and an Access database, see article Q316675 "PRB: Cannot Connect to Access Database from ASP.NET" in the Microsoft Knowledge Base located at URL

If you read the article on the MS site you should get some pointers on how to hack through this issue!

Reply With Quote
  #4  
Old December 16th, 2003, 03:27 PM
jpf jpf is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 jpf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Shouldn't the block:

Dim objReader as OleDbDataReader
objReader = objCommand.ExecuteReader()
datagrd.DataSource = objCommand.ExecuteReader()
datagrd.DataBind()


Read something more like:

Dim objReader as OleDbDataReader
objReader = objCommand.ExecuteReader()
datagrd.DataSource = objReader ' <--- Change here.
datagrd.DataBind()

Reply With Quote
  #5  
Old January 9th, 2004, 07:31 AM
hawkinsw hawkinsw is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: New Zeland
Posts: 3 hawkinsw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile Close one before opening another

Yes. I had this one. And it took me a good day to work out why it was doing this. And to make things hard, the error was not always in the same place.

As someone else said. remove the ; on the sql. This should not be there.

Also, this error happen when you have more then one connection open to the same access file. It is very important that you close one connection before you open another. If you say have a (for I loop or a while loop) and open a access connection. Look at a result, and based on this result then open another connection before closing the first one. Some times your code will work, sometimes it will not (that’s Access). I was walking day by day and seeing if a booking had been made. All worked ok, but if it had to walk more then 35 or so days in a while loop. The code would crash and bring up the error you are having.

Also do not forget to stop and start the IIS service. I found that after having this error. I could not connect to the database every time. If this is your live server to the world. I would do this without question.

I hope this helps

Wayne Hawkins
Network Manager
Christchurch Girls' High School

Last edited by hawkinsw : January 9th, 2004 at 06:07 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > Probs with reading AccessDB


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT