[Mono-list] Problems with Sqlite

Chris Turchin chris@turchin.net
Fri, 06 Feb 2004 20:40:39 +0100


hi,

hehehe, now i know what the mp3 library question earlier this week was
all about ;-)

i don't know much about the sqlite provider (though there is some sample
code in the mphoto module in cvs). 

this code worked for me though:

using System;
using System.Data;
using Mono.Data.SqliteClient;

class Test
{

	public static void Main()
	{
		string connectionString = "URI=file:music.db";
		IDbConnection dbcon;
		dbcon = new SqliteConnection(connectionString);
		dbcon.Open();
		IDbCommand dbcmd = dbcon.CreateCommand();
		dbcmd.CommandText = "INSERT INTO music (file, title, length, artist,
album, year, track,comment, bitrate, frequency, mode)
VALUES('/home/tapia/mono/mcatalog/plugins/prueba.mp3','prueba',170,'HenriMancini','Best Of...','',1,'',163,48000,'Stereo');";
		dbcmd.ExecuteNonQuery();
	}
}

regards,
--chris


On Fri, 2004-02-06 at 15:42, tapia wrote:
> Hi.
> 
> I'm working in a project using Mono.Data.SqliteClient, and I have a
> little problem. I have a SQL sentence, and if I execute it via the
> sqlite commandline interface it works fine, but if I execute it via
> Mono, the runtime show me this error:
> 
> Unhandled Exception: System.ApplicationException: Sqlite error near
> "'prueba": syntax error
> 
> The SQL sentence is here:
> 
> INSERT INTO music (file, title, length, artist, album, year, track,
> comment, bitrate, frequency, mode) VALUES
> ('/home/tapia/mono/mcatalog/plugins/prueba.mp3','prueba',170,'Henri
> Mancini','Best Of...','',1,'',163,48000,'Stereo')
> 
> And the table is here:
> 
> CREATE TABLE music (
> 	file STRING PRIMARY KEY NOT NULL,
> 	title STRING,
> 	length INTEGER,
> 	artist STRING,
> 	album STRING,
> 	year STRING,
> 	track INTEGER,
> 	comment STRING,
> 	bitrate INTEGER,
> 	frequency INTEGER,
> 	mode STRING)
> 
> Is there a Mono.Data.SqliteClient bug, or am I doing something wrong?
> 
> Thank you :-)
>