[Gambas-user] Rename a file in filesystem

Ron Onstenk ronstk at ...239...
Thu Jan 24 17:13:58 CET 2008


On Thursday 24 January 2008 15:44, Paolo Fagni wrote:
> This is kind of an annoying problem. I post here the sub that I would like
> to use to create a new sqlite file:  It doesn't work if, in the dialog, I
> chosse a neme with a point in it ("xxx.db for example")
> 
> ' Creates a new, empty, database.
> PUBLIC SUB CreateNew() AS Boolean
> 
>   TRY dbConnection.Close()
> 
>   Dialog.Path = Application.Path
>   Dialog.Title = ("Please choose a filename")
>   IF Dialog.SaveFile() THEN RETURN
>   DbPath = Dialog.Path
> 
>   IF Exist(DbPath) THEN ' Check if the file exists
>     Message.Error(("File already exists!"))
>     RETURN FALSE
>   ENDIF
> 
>   dbConnection.Name = DbPath
>   dbConnection.Type = "sqlite3"
>   dbConnection.Open()
> 
>   dbConnection.Close()
> END
> 
> 
> Gambas fails with "Unable to locate database : /path/to/xxx.db

Your database name is here 'xxx' and sqlite stores the data into the file 'xxx.db'
Not strange sqlite does not accept a name of 'xxx.db' here and tells gambas it
cant handle. I'm afraid gambas is not in error but sqlite or even better the user
is using wrong filename. 

It is not imposible sqlite does not accept a dot in the database name for 3 reasons.
1) it is used between the tablename and fieldname (i.e. tablename.fieldname)
2) it is used between the database and table name (i.e. databasename.tablename)
3) it is used as extention for the file name in the filesystem.

> 
> Gambas version 2.0.0 on an arch linux box.
> 
> Any help would be appreciated, Thank you! :D
> 
> 

Just try if you can create a database with the name xyx.abc
and use the commandline util for sqlite to do this (if exists)
If both, the .abc and .db, works than it may a problem with gambas.
But remember the database part of gambas must be able to work on many database 
systems and not all allow a dot in the database, table and/or field name.

Greets,

Ron Onstenk 




More information about the User mailing list