473,789 Members | 2,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'System.Data.Ol eDb.OleDbExcept ion' when creating a new DataSet..

It's still not working - is still looking for the Database in the same
folder as the photo just added.

But i've realised something... bear with me here! :)

The basics of the way my photo album works is as follows:

- A database containing photo_id (as a primary key), location
(location of photo on disk), caption etc are contained in a table in a
Database (photoDB.mdb) in the Debug folder of the project
- User opens the Photo Album program
- The Browse Photos form opens... in which photo id's are loaded from
a database into a ListBox
- When you select a photo id from the ListBox, it will get the file
location for that appropriate photo_id from the database and load it
into a picture box opposite the ListBox
- I use the same connection settings (to the database) for everything
- when the form loads, when the user selects a new photo id, when a
user deletes a photo... all works fine!
- But then clicking to open the Add Photo form then, i get the
problem!

I tried using the connection setting i've been using all along and it
looks for the Database in the same location (folder) as the photo i'm
adding. Tried using different form of connection settings /
suggestions i've been getting and they all end up the same: looking
for the database in the folder as the photo i'm adding.

However, if i skip the form involving Browsing The Photos, selecting
photos etc. and just go straight to the form to Add a new Photo.. that
connection setting works successfully and all is fine.

It's on when i load the Browsing Photo form.. and then try and open
the Add New Photo form that i get a problem.

Very long, detailed and confusing problem, i know!

By the way, i am closing the connection to the Database each time i
use it.

Any suggestions why the problem doesn't occur if i go straight to the
Add Photo form (bypassing the Browsing Photos form)? Would it be
because i'm re-using the same connection settings, variable names
(etc.) even though i'm closing the database after each method.

The connection string (that i'm re-using) is below:

string strDSN = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=photoDB. MDB";
string strSQL = "SELECT * FROM photos" ;
OleDbConnection myConn = new OleDbConnection (strDSN);
OleDbDataAdapte r myCmd = new OleDbDataAdapte r( strSQL, myConn );
myConn.Open();

DataSet dtSet = new DataSet();
myCmd.Fill( dtSet, "categories " );
DataTable dtAddTable = dtSet.Tables[0];

Then after that, i take the appropriate action (loading to a ListBox /
ComboBox) and close the connection to the database.

Any suggestions as to where i might be going wrong would be much
appreciated!

Thanks for all the help, Brian.
Nov 16 '05 #1
1 3104
Brian,

I think that I understand now! :-)

Instead of using the connection string:

Data Source=photoDB. MDB

You should get the path of the executable and append it to the Data Source
(this is slightly different than the code I gave you before…I didn’t know
that you were changing the environment path with an open dialog (or similar
control))

"...Data Source=" +
System.IO.Path. GetDirectoryNam e(System.Reflec tion.Assembly.G etExecutingAsse mbly().Location ) + @"\ photoDB.MDB ";

What I would suggest is that you create a variable (or property) in your
code that will store the connection string. This will provide ease of use in
your code and you will always retain the same location no matter what happens.

I hope this helps!
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5292
by: silesius | last post by:
I've been using VS 2003 to develop a webapplication using C#. Today I exported the application to a remote webserver I begun experiencing problems. It's a simple application that retrieves some information from an Access database. It worked fine when I ran on my computer. I use a parameterized query to retrieve some customer specific information. Customer logs in, I store the username they log in with in the session state and on the...
1
503
by: Brian | last post by:
Hello. Am getting an error message here at the line: DataSet dtSet = new DataSet(); Error is: "An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll" Bizarre as i'm using the same code elsewhere (besides the name of a table) to populate a listbox.
1
6898
by: T8 | last post by:
I have a asp.net (framework 1.1) site interfacing against SQL 2000. It runs like a charm 99% of the time but once in a while I get the following "unspecified error". Sometimes it would resolve by itself (asp.net recycled?); it also can be solved by restarting IIS. Any ideas what cause(s) this to happen? System.Data.OleDb.OleDbException: Unspecified error at System.Data.OleDb.OleDbDataReader.ProcessResults(Int32 hr) at...
1
8955
by: Roger Twomey | last post by:
I have a form that allows a user to upload a microsoft Excel Spreadsheet. (I am testing with one created in Excel 2000) The spreadsheet is uploaded correctly. It is then supposed to be read and display in a datagrid. When the code executes I get: System.Data.OleDb.OleDbException: Could not find installable ISAM
0
2783
by: silesius | last post by:
I've been using VS.NET 2003 to develop a webapplication using C#. Today I exported the application to another webserver I begun experiencing problems. It's a simple application that retrieves some information from an Access database. It worked fine when I ran on my home computer. I use a datagrid witha a dataset and a parameterized query to retrieve some customer specific information. Customer logs in, I store the username they log in...
0
5676
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable) at System.Data.Common.DbDataAdapter.Update(DataSet dataSet) at TryThis.Form1.save() in C:\Documents and Settings\Nick\My Documents\...
5
9652
by: petro | last post by:
Hello all, My asp.net web application works on my machine but I get the following error on our test web server, There is only one oracle home on the test server. Does anyone know how to resolve this error? Oracle error occurred, but error message could not be retrieved from Oracle. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the...
6
15418
by: Learner | last post by:
Hi there, I am trying to access the access database sitting at OleDbConnection oleConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Crystal Reports\\Samples\\Database\\xtreme.mdb"); and create a crystal report using c#. I have done every thing but for some reaspon when i try running my webform its throing the below error.
0
1644
by: John G | last post by:
I have been using Oracle Helper to connect to my oracle 9i Db. When excute text it works fine, but when I try to execute a store procedure I get the following error message. I searched everyplace for a solution. System.Data.OleDb.OleDbException: ̸Ώ System.Data.OleDb.OleDbCommand.ExecuteCommandTextForMultpleResults(tagDBPARAMS dbParams, Object& executeResult) +161
2
9006
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application. -------------------------------------------------------------------------------- Data type mismatch in criteria expression.
0
9661
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10193
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9978
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9015
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7524
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6755
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2904
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.