none
Conection String RRS feed

  • Question

  • I am unsure of the way a conection string looks like.

    This is what I am trying. I am looking for the one that uses something like spesial directory so I dont hav to use M

    My memory is faling my.

     Private connString As String = "Data Source=M:\My Documents\My Resepte\MainDishes.accdb"

    Monday, January 20, 2020 11:02 AM

Answers

  • Your connection string should look like this

    Private ConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\MainDishes.accdb"

    If this fails one thought is the spaces in the path


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, January 20, 2020 4:54 PM
    Moderator

All replies

  • Hi,
    for ConnectionStrings see https://www.connectionstrings.com/.

    Try this ConnectionString:

    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\MainDishes.accdb;Persist Security Info=True


    --
    Best Regards / Viele Grüße
    Peter Fleischer (former MVP for Developer Technologies)
    Homepage, Tipps, Tricks

    Monday, January 20, 2020 11:11 AM
  • . I am looking for the one that uses something like spesial directory so I dont hav to use M

    For MyDocuments, you can do :

    Dim sMyDocumentsPath As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

    Monday, January 20, 2020 11:13 AM
  • This stil seems not to work.

     Private connString As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) \ "My Resepte\MainDishes.accdb"

    Monday, January 20, 2020 11:27 AM
  • This works for me :

    Dim sMyDocumentsPath As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
    Dim sConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + sMyDocumentsPath + "\My Resepte\MainDishes.accdb;Persist Security Info=False;"

    Monday, January 20, 2020 11:50 AM
  • I seem to have the conection string working, not what I wanted thow,  

    I keep geting this error. 

    Monday, January 20, 2020 12:16 PM
  • Your connection string is WRONG

    Read answers...

    Monday, January 20, 2020 12:43 PM
  • Still the same errot with this.

     Dim sMyDocumentsPath As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
        Dim sConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + sMyDocumentsPath + "\My Resepte\MainDishes.accdb;Persist Security Info=False;"
        Dim connString As String = sConnString

    Monday, January 20, 2020 12:59 PM
  • Your connection string should look like this

    Private ConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\MainDishes.accdb"

    If this fails one thought is the spaces in the path


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, January 20, 2020 4:54 PM
    Moderator