in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

datasource location in connection string

Last post 01-01-2006 7:36 PM by Robert Simpson. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 12-31-2005 9:28 PM

    • netsql
    • Top 200 Contributor
    • Joined on 12-31-2005
    • Posts 5

    datasource location in connection string

    I created a "db" using lite 3 and now I want to connect to it from c#.
    How do I specify the directory at design time (and run time?) of the file.
    If I just use filename and put that file in the debug folder it does not see it I think since it does not see the tables.
    help.

    tia,
    .V
  • 12-31-2005 10:56 PM In reply to

    Re: datasource location in connection string

    Read the sqlite.net help file and look at SQLiteConnection.  The ConnectionString property is where you specify the data source and other properties of the connection.

    Robert

     

  • 01-01-2006 9:55 AM In reply to

    • netsql
    • Top 200 Contributor
    • Joined on 12-31-2005
    • Posts 5

    Re: datasource location in connection string

    Using sql lite I create the db and create tables. When I conect to it using "sql explorer" it does not show the tables. So I must be conecting to the wrong one. Where should I put the "db" file and how do I specify the folder in connection string?
    Ex: "datasource=../folder/mydb.db3

    tia,
    .V
  • 01-01-2006 1:53 PM In reply to

    Re: datasource location in connection string

    You can put the DB file anywhere you like.  For example, here's a connection string to connect to a database at C:\test.db

    SQLiteConnection cnn = new SQLiteConnection("Data Source=c:\test.db");

    When you say "I connect to it using sql explorer" -- I'm not sure what you're talking about.

    Here's a video I made of me in Visual Studio creating a new connection, creating a table, inserting data into it and creating a typed dataset using Visual Studio and all the design-time support features of SQLite:

     

  • 01-01-2006 7:25 PM In reply to

    • netsql
    • Top 200 Contributor
    • Joined on 12-31-2005
    • Posts 5

    Re: datasource location in connection string

    thank you. hardcoding the full path works.

    I guess in production I got to change the string to not having the path so that it finds it in same folder as application ?
    Like if I do click once or smart client.

    .V
  • 01-01-2006 7:36 PM In reply to

    Re: datasource location in connection string

    If the database is in the same folder as the executable, just specify no path information.  "Data Source=test.db" will look in the "current" directory.  If the database is in a subdirectory relative to the executable, just use a relative path.  "..\datafiles\test.db" or "..\..\test.db" etc.

    Robert

     

Page 1 of 1 (6 items)
Powered by Community Server (Commercial Edition), by Telligent Systems