locked
connection string for access RRS feed

  • Question

  • hi all, i have the connection string

    cn = New OleDbConnection("Provider=Microsoft.Ace.OLEDB.12.0; Persist Security Info = False;" & _
    
        "Data Source=C:\printtest2.accdb;")
    which works fine but my database is in the server in a network what additional details do i need for the connection string

    The server name is as follows

    "Prntsvr-Test.auhbr.ctrixa.ad"

    how do i use the connection string

    Thanks
    Roma
    • Edited by roma_victa Wednesday, December 9, 2009 10:32 AM
    Wednesday, December 9, 2009 9:46 AM

Answers

  • You need to specify the UNC path (e.g. \\servername\sharename\folder\printtest2.accdb).


    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Proposed as answer by Cor Ligthert Wednesday, December 9, 2009 6:29 PM
    • Marked as answer by roma_victa Thursday, December 10, 2009 5:25 AM
    Wednesday, December 9, 2009 3:50 PM

  • "can you show me a sample connection string "



    The connection string is still like usually, but if you use dynamic path, then you don't have to identify your database path (in server) in source code.

    (e.g. \\servername\sharename\folder\printtest2.accdb ). << this could be your path, but it's static, considering that ms access file can be moved easily.

    Make one form to browsing database file, use OpenFileDialog, and you will get dynamic path from your database file in server.

    You could save your current database path in text file if you want to, so your application has to check that text file first before running application.

    Next time if your database will be moved, then you don't have to worry changing your path in source code, just simple click browse and you will get another new path  ;)
    • Marked as answer by YiChun Chen Thursday, December 10, 2009 8:04 AM
    Thursday, December 10, 2009 3:04 AM

All replies


  • Have you use dynamic path, where you can select from any path you want??
    Wednesday, December 9, 2009 9:59 AM
  • can you show me a sample connention string

    Wednesday, December 9, 2009 10:14 AM
  • If the Access file is not reachable for the user in a common way, then you cannot connect to it on a Server.

    An Access file is not an DataBase Server like Oracle and SQL Server

    You have to give the user proper rights to get access to that file.
    (A system administrator job, you cannot do that from your program)
    Success
    Cor
    Wednesday, December 9, 2009 11:39 AM
  • hi core thank for the replay

    i have the rights and i can log in to the server as well( in fact i have administrative privilages on this server )

    in normal case i can just use the below connection string to acces the database locally
    cn = New OleDbConnection("Provider=Microsoft.Ace.OLEDB.12.0; Persist Security Info = False;" & _
        "Data Source=C:\printtest2.accdb;")
                cn.Open()

    but what alteration can i male to access the same from the server where the  server name is

    Prntsvr-Test.auhbr.ctrixa.ad

    Thanks

    Wednesday, December 9, 2009 12:00 PM
  • hi core thank for the replay

    i have the rights and i can log in to the server as well( in fact i have administrative privilages on this server )

    in normal case i can just use the below connection string to acces the database locally
    cn = New OleDbConnection("Provider=Microsoft.Ace.OLEDB.12.0; Persist Security Info = False;" & _
        "Data Source=C:\printtest2.accdb;")
                cn.Open()

    but what alteration can i male to access the same from the server where the  server name is

    Prntsvr-Test.auhbr.ctrixa.ad

    Thanks

    I think you need to provide the IP address as well.

    have a look here: www.connectionstrings.com/

    Don't judge me, just Upgrade me. Thanks!
    Wednesday, December 9, 2009 1:17 PM
  • You need to specify the UNC path (e.g. \\servername\sharename\folder\printtest2.accdb).


    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Proposed as answer by Cor Ligthert Wednesday, December 9, 2009 6:29 PM
    • Marked as answer by roma_victa Thursday, December 10, 2009 5:25 AM
    Wednesday, December 9, 2009 3:50 PM

  • "can you show me a sample connection string "



    The connection string is still like usually, but if you use dynamic path, then you don't have to identify your database path (in server) in source code.

    (e.g. \\servername\sharename\folder\printtest2.accdb ). << this could be your path, but it's static, considering that ms access file can be moved easily.

    Make one form to browsing database file, use OpenFileDialog, and you will get dynamic path from your database file in server.

    You could save your current database path in text file if you want to, so your application has to check that text file first before running application.

    Next time if your database will be moved, then you don't have to worry changing your path in source code, just simple click browse and you will get another new path  ;)
    • Marked as answer by YiChun Chen Thursday, December 10, 2009 8:04 AM
    Thursday, December 10, 2009 3:04 AM
  • Thanks Paul its now working is there any other way arround it
    Thursday, December 10, 2009 6:46 AM
  • Thanks Paul its now working is there any other way arround it

    I'm not sure what you are asking but the only other method would be to map a drive letter to the resource. The use of a UNC path is the best method.

    If you want the location to be dynamic (selected at application runtime) then use the OpenFileDialog suggestion posted by Harrie KalaChakra.
    Paul ~~~~ Microsoft MVP (Visual Basic)
    Thursday, December 10, 2009 1:07 PM