473,326 Members | 2,124 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,326 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 2436
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...
1
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.