Help please: Physical file/Datasource name vs. aliased name

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
graf_eberstein
Posts: 2
Joined: Fri 01 Apr 2011 20:21

Help please: Physical file/Datasource name vs. aliased name

Post by graf_eberstein » Fri 01 Apr 2011 21:11

Please note: I'm fairly new to VB.net and dotConnect (about two weeks), but have previously coded in VB6. Please keep this in mind as you read this and formulate a reply to my question.

When I coded in VB6, I used a wrapper called dhRichClient to talk with my database. One of the things dhRichClient allows when creating a database is something I've been unsuccessful with in dotConnect: Assigning an alias to the database.

I'm using ConnectionStringBuilder and using the example shown in the dotConnect documentation, but with my path and filename for the datasource. Essentially:

Code: Select all

Dim connSB As SQLiteConnectionStringBuilder
connSB.DataSource = "D:\TestApplication\database.db"
connSB.FailIfMissing = false
connSB.Locking = LockingMode.Exclusive
connSB.AutoVacuum = AutoVacuumMode.Full
connSB.ConnectionTimeout = 20
Dim sqLiteConnection1 As SQLiteConnection(connSB.ConnectionString)
I know that since the file does not exist, invoking sqLiteConnection1.Open() will create the file specified by connSB.DataSource. When tables are added, they are added to "database" under this scheme.

But: Suppose I want the database to have an alias (lets say, "DBAlias" for sake of example). How would I go about this so that when I do my transactions later in the application, I can use the alias instead? In other words:

Code: Select all

SELECT [Desc] FROM [DBAlias] WHERE [InStock]=1;
instead of

Code: Select all

SELECT [Desc] FROM [database] WHERE [InStock]=1;
I could do this with dhRichClient, and while my knowledge is limited, I know it is not endemic to that wrapper. So how do I accomplish this with dotConnect? The end result must be one where the application creates and configures the database, and generates the tables the first time it is run. Am I on the wrong track altogether?

In case it matters, I'm using VB.net 2008 and the standard (free) version of dotConnect (3.10.121, I believe --which brings up a different question: How do I poll the wrapper to return its version?)

Thanks!

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Help please: Physical file/Datasource name vs. aliased name

Post by Shalex » Tue 05 Apr 2011 15:08

graf_eberstein wrote:But: Suppose I want the database to have an alias (lets say, "DBAlias" for sake of example). How would I go about this so that when I do my transactions later in the application, I can use the alias instead? In other words:

Code: Select all

SELECT [Desc] FROM [DBAlias] WHERE [InStock]=1;
instead of

Code: Select all

SELECT [Desc] FROM [database] WHERE [InStock]=1;
You should implement your own logic to use aliases for constructing queries in your code. For example:
string tableName = "dept";
....
sqliteCommand.CommandText = "select * from " + tableName + " WHERE Deptno=1;"
graf_eberstein wrote:How do I poll the wrapper to return its version?
Could you please explain which wrapper and whose version should return?
You can check the dotConnect for SQLite version via the Tools > SQLite > About menu of Visual Studio or via properties of the Devart.Data.SQLite.dll assembly.

graf_eberstein
Posts: 2
Joined: Fri 01 Apr 2011 20:21

Re: Help please: Physical file/Datasource name vs. aliased name

Post by graf_eberstein » Sun 10 Apr 2011 18:11

Shalex wrote:You should implement your own logic to use aliases for constructing queries in your code. For example:
string tableName = "dept";
....
sqliteCommand.CommandText = "select * from " + tableName + " WHERE Deptno=1;"
That part I know, but isn't what I was asking, I'm afraid. What I am looking for is what SQLiteExpert (http://www.sqliteexpert.com/) defines as "Database Registration". This allows you to have a physical file with one name, containing a database with a different one. Sorry, but that's as close as I can get with this...

Meanwhile:
Shalex wrote:
graf_eberstein wrote:How do I poll the wrapper to return its version?
Could you please explain which wrapper and whose version should return?
I finally figured this one out. I was looking for was

Code: Select all

Devart.Data.SQLite.ProductInfo.VersionBase

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 12 Apr 2011 16:28

As I understood from the SQLite Expert documentation, "alias" is only name that will be displayed in Database Explorer for particular physical database file. No other use. Correct me if I am wrong.

In what cases do you need an alias for the database file when using dotConnect for SQLite?

Post Reply