Results 1 to 3 of 3

Thread: [RESOLVED] Variable in Connection String

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    58

    Resolved [RESOLVED] Variable in Connection String

    My program asks the user for the location of the database and stores the location in the variable "filename"

    I then have this:
    Dim ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filename

    but apparently I can't do that. What am I missing here?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Variable in Connection String

    You certainly can do that. A connection string is just a string, so how you build it is irrelevant. Of course, the end result has to be valid so, if it's not working, that would presumably be the reason.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    58

    Re: Variable in Connection String

    I'm sorry. It was complaining about the & sign, and that made me not consider my "filename" variable being invalid. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width