PC Review


Reply
Thread Tools Rate Thread

Connection syntax not right

 
 
Kimberley Wiggins
Guest
Posts: n/a
 
      28th Feb 2004
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!
 
Reply With Quote
 
 
 
 
Bernie Yaeger
Guest
Posts: n/a
 
      28th Feb 2004
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" <(E-Mail Removed)> wrote in message
news:eycU3vZ$(E-Mail Removed)...
> 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!



 
Reply With Quote
 
Richard T. Edwards@pwpsquared.net
Guest
Posts: n/a
 
      28th Feb 2004
Assumming this Application.Startuppath is where the mdb is located:
Data Source = Application.StartupPath "\otr.mdb"

"Kimberley Wiggins" <(E-Mail Removed)> wrote in message
news:eycU3vZ$(E-Mail Removed)...
> 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!



 
Reply With Quote
 
Kimberley Wiggins
Guest
Posts: n/a
 
      28th Feb 2004

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!
 
Reply With Quote
 
Kimberley Wiggins
Guest
Posts: n/a
 
      28th Feb 2004

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!
 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      28th Feb 2004
Hi Kimberley,

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

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

Cor


 
Reply With Quote
 
Bernie Yaeger
Guest
Posts: n/a
 
      28th Feb 2004
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" <(E-Mail Removed)> wrote in message
news:O985tLa$(E-Mail Removed)...
>
> 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!



 
Reply With Quote
 
Charlie Smith
Guest
Posts: n/a
 
      28th Feb 2004
Kimberley Wiggins <(E-Mail Removed)> wrote in message news:<eycU3vZ$(E-Mail Removed)>...
> 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
 
Reply With Quote
 
Kimberley Wiggins
Guest
Posts: n/a
 
      1st Mar 2004
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!
 
Reply With Quote
 
Chris Dunaway
Guest
Posts: n/a
 
      1st Mar 2004
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax problem (vb) data connection slinky Microsoft ASP .NET 4 10th Aug 2007 04:40 PM
ADO Connection String Syntax =?Utf-8?B?VmF1Z2hhbg==?= Microsoft Outlook VBA Programming 6 24th Jan 2005 04:27 PM
LDAP connection syntax Steve House Microsoft Outlook Discussion 6 11th Oct 2004 11:08 AM
Syntax for New and Set with ADODB.Connection Max Moor Microsoft Access Form Coding 4 25th May 2004 12:53 AM
dotNet - syntax for parms in SQL Connection? kate Microsoft ADO .NET 2 12th Aug 2003 06:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:44 AM.