Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 383
  • Last Modified:

Path Specification In Connection String (VB.NET)


Hi

At thhe start of my Application's Module I have the following code:

Public sPath As String

When my application starts, I have the following code:

sPath = Application.StartUpPath
 
My Connection String looks like this:
         QtCon.ConnectionString = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=C:\Mayibuye\Quotations.accdb"

Now for obvious reasons, when I deploy the Application, I need to include the definition of Path into this connection. When I use sPath immediately after DataSource=, then I get an error with the following description:

"Format Of The Initialisation String Does Not Conform To Specification."

I am sure there must be a good (or better) way of doing this. Can somebody help me please.

I am Using VB.NET (Visual Studio 2008) under Windows XP Pro.

Thanks


0
Nolanc
Asked:
Nolanc
2 Solutions
 
Carl TawnSystems and Integration DeveloperCommented:
How are you using sPath in the string? Are you literally adding it into the string, or are you doing something like:

QtCon.ConnectionString = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=" & sPath & "\Quotations.accdb"

Open in new window

0
 
Dennis AriesCEO @ Arkro ITCommented:

What line did you try exactly?

QtCon.ConnectionString = String.Format("Provider=Microsoft.Ace.OLEDB.12.0;Data Source={0}\Quotations.accdb", sPath)

usually works.
0
 
NolancAuthor Commented:
Hi carl tawn and dijaries

Thanks for your prompt responses. The fact of the matter is, I messed up the syntax. Either of the syntaxt suggested by you works perfectly.

Many thanks.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now