473,396 Members | 1,968 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,396 software developers and data experts.

Connection syntax not right

Can someone please tell me what is wrong with this syntax? I am just
really frustrated. I am trying to use the application startup path for
this but it does not like this syntax for some reason. Does something
look out of place here?

Dim strOTRConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source= Application.Startup & otr.mdb"

I know this is the problem because if I move my database to my C drive
it works fine.
Thanks


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
12 1126
Hi Kim,

First of all, you don't have an opening quote before otr.mdb" (s/b
"otr.mdb"). Also, debug or messagebox.show to get the actual string
represented by application.startup - do you have to append "\" to it?

HTH,

Bernie Yaeger

"Kimberley Wiggins" <ki********@greenwaymedical.com> wrote in message
news:ey**************@TK2MSFTNGP10.phx.gbl...
Can someone please tell me what is wrong with this syntax? I am just
really frustrated. I am trying to use the application startup path for
this but it does not like this syntax for some reason. Does something
look out of place here?

Dim strOTRConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source= Application.Startup & otr.mdb"

I know this is the problem because if I move my database to my C drive
it works fine.
Thanks


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #2
Assumming this Application.Startuppath is where the mdb is located:
Data Source = Application.StartupPath "\otr.mdb"

"Kimberley Wiggins" <ki********@greenwaymedical.com> wrote in message
news:ey**************@TK2MSFTNGP10.phx.gbl...
Can someone please tell me what is wrong with this syntax? I am just
really frustrated. I am trying to use the application startup path for
this but it does not like this syntax for some reason. Does something
look out of place here?

Dim strOTRConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source= Application.Startup & otr.mdb"

I know this is the problem because if I move my database to my C drive
it works fine.
Thanks


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #3

No I don't have to append to it and I debugged it to find out the
application startup path and I do have the database in the correct path.
You said I did not have an opening quote before otr.mdb, it doesn't like
that. It tells me that a end of statement is expected when I put one
there. No, I don't have to append to the file, just display.
Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #4

Thanks Richard but it doesn't like that. It tells me otr is not
declared and end of statement expected at the end. I don't know how to
fix the end of statement expected. I have debugged the path and yes the
file is in the right path.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #5
Cor
Hi Kimberley,

Richard forgot the & but that is such a easy to sea typo.

Data Source = Application.StartupPath & "\otr.mdb"

Cor
Nov 20 '05 #6
Hi Kimberly,

You have to have otr.mdb attached via "otr.mdb"; if the syntax isn't
correct, it isn't the fault of this; you can't attach a string to an
ampersand with only the outer quote.

This is undoubtedly where the error is - once you attach it with the double
quotes, print it out in a messagebox.show and let me see it.

Bernie

"Kimberley Wiggins" <ki********@greenwaymedical.com> wrote in message
news:O9**************@TK2MSFTNGP11.phx.gbl...

No I don't have to append to it and I debugged it to find out the
application startup path and I do have the database in the correct path.
You said I did not have an opening quote before otr.mdb, it doesn't like
that. It tells me that a end of statement is expected when I put one
there. No, I don't have to append to the file, just display.
Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #7
Kimberley Wiggins <ki********@greenwaymedical.com> wrote in message news:<ey**************@TK2MSFTNGP10.phx.gbl>...
Can someone please tell me what is wrong with this syntax? I am just
really frustrated. I am trying to use the application startup path for


Kimberley,

I have struggled with the same issue and solved it this way:

Dim dbPath as string = Application.Startup & "\otr.mdb"

Dim strOTRConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source= dbPath"

The problem is that the connection string must be enclosed in quotes,
but concatenation also requires it for the second half of the dbPath
you are defining.

Charlie
Nov 20 '05 #8
Thank you so much Charlie. Thanks everyone for your input. Charlie you
explained it to me why I should have it the way it is. I needed to know
exactly what was the essential pieces that needed to be there because I
had tried so many things to make the it work I didn't know what was
right from wrong. It worked and everything's good. Once again, thanks.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #9
On 28 Feb 2004 10:40:08 -0800, Charlie Smith wrote:
I have struggled with the same issue and solved it this way:

Dim dbPath as string = Application.Startup & "\otr.mdb"

Dim strOTRConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source= dbPath"


I think you have a typo. Shouldn't that last line be:

Dim strOTRConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" & dbPath

?

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #10
Cor
Hi Chris,

I had the same idea as you strange that it did work as Kimberley said.

:-)

Cor

I think you have a typo. Shouldn't that last line be:

Dim strOTRConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" & dbPath

Nov 20 '05 #11
"Cor" <no*@non.com> wrote in message news:<uR**************@TK2MSFTNGP11.phx.gbl>...
Hi Chris,

I had the same idea as you strange that it did work as Kimberley said.


This is one of the strangest postings I've ever seen.

First, how can someone be working with a database when they are having
so much trouble doing a simple string concatenation? That's one of
the first things you learn in programming, and you should certainly
know this before attempting database connections!

Second, the code that was just posted couldn't have possibly solved
the problem, as the variable name was enclosed in the string. Am I
missing something?
Nov 20 '05 #12
"Cor" <no*@non.com> wrote in message news:<uR**************@TK2MSFTNGP11.phx.gbl>...
Hi Chris,

I had the same idea as you strange that it did work as Kimberley said.


Cor,

AFAIK this is a pecularity of Access database connection strings. I
have never dug into the thoery, but I have learned how to make it
work. You know the old saying about necessity is a mother...

Charlie
Nov 20 '05 #13

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

Similar topics

6
by: Andy Wawa | last post by:
Hi, on a simple HTML (not an ASP!)-Site I try to connect to a sql server (MS): <html> <title>Test</title> <head> <script language="javascript"> <!-- Function showForm(){
1
by: GrantS | last post by:
I am unable to get the connection to work with using the app.config file. the connection works when I use 'in line' connection as below:...
3
by: Jon Booth | last post by:
I have just started programming .NET having come from ASP. We used to create a connection and store it in a session.This meant for each user logging into the site there was only one connection ...
5
by: tshad | last post by:
I can't seem to find where to reset the parameter list. Dim objCmd as New SqlCommand(CommandText,objConn) with objCmd.Parameters .Add("@StateCode",SqlDbType.Char,2).value = ByState.SelectedValue...
7
by: Steve Franks | last post by:
Using VS.NET 2005 RC - Am I understanding correctly from the docs that connection pooling for my ADO.NET db connections will happen automatically? Do I need to do anything to enable this feature? ...
6
by: jonefer | last post by:
I have two versions of a 'Downtime Application that will run in the event that the mainframe goes down 1) SQL Server ASP.NET app (accessed outside the mainframe network) 2) MS Access Version of...
5
by: Darrel | last post by:
I've been taught that, at least in 1.1, you put your DB connection strings in the WebConfig file and access them from there as needed. In 2.0, it looks like I can do the same, but it's been...
9
by: nbs.tag | last post by:
hey guys heres my question. I was told by a little birdie that .net 2.0 has the ability to read a connection string directly from a registry key. so in the registry key a string value of say :...
2
by: Venkata Narayana | last post by:
Hi, You all may be knowing that Connection.isClosed() does not tells us if the underying DB connection is active or not; it only checks if Connection.close() had been previously called or not....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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 project—planning, coding, testing,...

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.