473,322 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Application.StartupPath and mdb problem

Howdy,

I've spent a good 2 or 3 hours this morning trying to figure out this
code. I'm new to the .Net environment and have some VB6 skills but
that was 3 years ago.

My project I'm working on accesses a Access DB to pull in data. I used
the designer to pull in the components I needed to connect to the
database.

Here is my Code:

Me.OleDbConnection1.ConnectionString = "Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Data Source=""C:\Owens\Visual Studio
Projects\Tailoring\bin\tailori" & _
"ng.mdb"";Mode=Share Deny None;Jet OLEDB:Engine
Type=5;Provider=""Microsoft.Jet.OLE" & _
"DB.4.0"";Jet OLEDB:System database=;Jet
OLEDB:SFP=False;persist security info=Fal" & _
"se;Extended Properties=;Jet OLEDB:Compact Without Replica
Repair=False;Jet OLEDB" & _
":Encrypt Database=False;Jet OLEDB:Create System
Database=False;Jet OLEDB:Don't C" & _
"opy Locale on Compact=False;User ID=Admin;Jet OLEDB:Global
Bulk Transactions=1"

I think this is a bit over kill, but what I'm trying to do is get it
so that I can put in the relative path to the database instead of
literal. However, when I change the datasource path it gives me an
error with my dataset.

Example of that code here:

Dim dbPath as String =
Application.StartupPath & "\tailoring.mdb"

Me.OleDbConnection1.ConnectionString = "Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Data
Source=[b:6e962dc7b3]dbPath[/b:6e962dc7b3];Mode=Share Deny None;Jet
OLEDB:Engine Type=5;Provider=""Microsoft.Jet.OLE" & _
"DB.4.0"";Jet OLEDB:System database=;Jet
OLEDB:SFP=False;persist security info=Fal" & _
"se;Extended Properties=;Jet OLEDB:Compact Without Replica
Repair=False;Jet OLEDB" & _
":Encrypt Database=False;Jet OLEDB:Create System
Database=False;Jet OLEDB:Don't C" & _
"opy Locale on Compact=False;User ID=Admin;Jet OLEDB:Global
Bulk Transactions=1"

This is the Error I get when I attempt to run it with that code.

An unhandled exception of type 'System.Data.OleDb.OleDbException'
occurred in system.data.dll

Code for that line is: OleDbDataAdapter1.Fill(DataSet1)

Anyone have any suggestions?

Nov 21 '05 #1
3 2435
Ddraig,

I have send this message this morning to Barkster (and when you see there he
showed that it did work for him)

I can let you search, however I copied it.

I have strugled a longtime with this and it is so easy, just set in the load
event from your form (or whatever place, before the connection object is
used however after that it is initialized) using the connection object you
have created with the designer (and don't change that in the designer
generated code) the connection string.

Someting as
OleDBConnection1.connectionstring = "xxxxxxxxxxxxx" & applicationstartuppath

Mostly those connection strings do not have that difficult as build with the
designer, have a look at these links for them.

http://www.connectionstrings.com/

http://www.able-consulting.com/ADO_Conn.htm

I hope this helps?

Cor
Nov 21 '05 #2
Ddraig,

I have send this message this morning to Barkster (and when you see there he
showed that it did work for him)

I can let you search, however I copied it.

I have strugled a longtime with this and it is so easy, just set in the load
event from your form (or whatever place, before the connection object is
used however after that it is initialized) using the connection object you
have created with the designer (and don't change that in the designer
generated code) the connection string.

Someting as
OleDBConnection1.connectionstring = "xxxxxxxxxxxxx" & applicationstartuppath

Mostly those connection strings do not have that difficult as build with the
designer, have a look at these links for them.

http://www.connectionstrings.com/

http://www.able-consulting.com/ADO_Conn.htm

I hope this helps?

Cor
Nov 21 '05 #3
Thanks for the help :) I was able to figure it out it was a problem
with the silly " marks they always get me. :roll:

Nov 21 '05 #4

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

Similar topics

3
by: ALI-R | last post by:
Hi The default direcoty when debugging the appication is always "...\myC#proramme\bin\Debug" and cuases problem because my xml files are in "...\myC#proramme" . Is there a way of getting the...
5
by: Robert Magnusson | last post by:
Hi All, This is sure to be an easy question. I am wondering what the accepted standard is for referencing a sub-folder below the application.exe folder? In VB6 you simply used App.Path and...
5
by: Eranga | last post by:
In c# windows applicatiopns the Application.StartupPath can be used to find the path for the executable file. How can the same be found for a console application?(we can't use application because...
8
by: jcrouse | last post by:
I am trying to run a command from a command prompt using the shell command. Here is the syntax I want to execute: Shell(lblMameExePath.Text & " -listinfo >" & Application.StartupPath &...
7
by: Q | last post by:
Hello you all, I have created an application that reads and writes data to a access database. To access the database, I use a System DataSource (Connection string: DSN=MyDataSourceName). If...
2
by: Ron | last post by:
Hello, I would like to retrieve the startupPath from a console application. It appears that a console application does not recognize Application, so I can't access StartupPath. Is there a way...
3
by: hayworth | last post by:
I had some code to build the name of a file: ' Build the name of the XML config file. g_strFiles.strConfig = My.Computer.FileSystem.CombinePath(Application.StartupPath, "\Settings\Config...
4
by: Rick | last post by:
I have a VB.Net 2005 application that I am publishing to a network file server. The app reads an xml file that has some database connection information in it. This xml file is located in the...
0
by: =?Utf-8?B?Sm9iIExvdA==?= | last post by:
I am using BulkLoad from .NET application as follows SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class obj = new SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class(); obj.ConnectionString =...
3
by: Joca | last post by:
I'm making a program that at some point needed to know what the path to it's own directory was, so i quickly made a side project just to test how this works ending up with the use of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.