473,394 Members | 1,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

SQLite / Mono trouble ?

Hi all,

I'm trying to use the sql engine SQLite within my Visual C# project. I
downloaded the mono version of the .NET framework so I could use
Mono.Data.SqliteClient.dll , however I can't seem to be able to use the
IDataReader object. Any suggestions ?

Complete work directory:
http://home.wanadoo.nl/hgvl/Copy%20of%20SqliteTest.zip

This is my code:
-----------------------------
using System;
using System.Data;
using Mono.Data.SqliteClient;

namespace SqliteTest
{
/// <summary>
/// Summary description for SqliteTestApp.
/// </summary>
class SqliteTestApp
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string connectionString = "URI=file:SqliteTest.db";
IDbConnection dbcon;
dbcon = new SqliteConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd;
dbcmd = dbcon.CreateCommand();
dbcmd.Connection = dbcon;
string sql = "CREATE TABLE test (nummer int)";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
sql = "INSERT INTO test VALUES (12)";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
sql = "SELECT nummer FROM test";
dbcmd.CommandText = sql;
IDataReader reader;
reader = dbcmd.ExecuteReader();
while (reader.Read())
{
int nummer = reader.GetInt32(0);
Console.WriteLine(nummer);
}
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}
}

Thanks in advance,

Rick van Lieshout
Nov 15 '05 #1
3 5137
Don't create the reader on one line then set it the next. Instead you create
it as a returned result on the same line:

don't do:
IDataReader reader;
reader = dbcmd.ExecuteReader();

Do this instead:
IDataReader reader = dbcmd.ExecuteReader();
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"Rick van Lieshout" <r.************@promo-it.nl> wrote in message
news:4Y********************@castor.casema.net...
Hi all,

I'm trying to use the sql engine SQLite within my Visual C# project. I
downloaded the mono version of the .NET framework so I could use
Mono.Data.SqliteClient.dll , however I can't seem to be able to use the
IDataReader object. Any suggestions ?

Complete work directory:
http://home.wanadoo.nl/hgvl/Copy%20of%20SqliteTest.zip

This is my code:
-----------------------------
using System;
using System.Data;
using Mono.Data.SqliteClient;

namespace SqliteTest
{
/// <summary>
/// Summary description for SqliteTestApp.
/// </summary>
class SqliteTestApp
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string connectionString = "URI=file:SqliteTest.db";
IDbConnection dbcon;
dbcon = new SqliteConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd;
dbcmd = dbcon.CreateCommand();
dbcmd.Connection = dbcon;
string sql = "CREATE TABLE test (nummer int)";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
sql = "INSERT INTO test VALUES (12)";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
sql = "SELECT nummer FROM test";
dbcmd.CommandText = sql;
IDataReader reader;
reader = dbcmd.ExecuteReader();
while (reader.Read())
{
int nummer = reader.GetInt32(0);
Console.WriteLine(nummer);
}
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}
}

Thanks in advance,

Rick van Lieshout

Nov 15 '05 #2
Sorry, this didn't do the trick.. I guess it is the callback function.. I'll
try a older DLL as soon as i can access the sqlite.org site again.

"Mark Fitzpatrick" <ma******@fitzme.com> wrote in message
news:OB**************@tk2msftngp13.phx.gbl...
Don't create the reader on one line then set it the next. Instead you create it as a returned result on the same line:

don't do:
IDataReader reader;
reader = dbcmd.ExecuteReader();

Do this instead:
IDataReader reader = dbcmd.ExecuteReader();
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"Rick van Lieshout" <r.************@promo-it.nl> wrote in message
news:4Y********************@castor.casema.net...
Hi all,

I'm trying to use the sql engine SQLite within my Visual C# project. I
downloaded the mono version of the .NET framework so I could use
Mono.Data.SqliteClient.dll , however I can't seem to be able to use the
IDataReader object. Any suggestions ?

Complete work directory:
http://home.wanadoo.nl/hgvl/Copy%20of%20SqliteTest.zip

This is my code:
-----------------------------
using System;
using System.Data;
using Mono.Data.SqliteClient;

namespace SqliteTest
{
/// <summary>
/// Summary description for SqliteTestApp.
/// </summary>
class SqliteTestApp
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string connectionString = "URI=file:SqliteTest.db";
IDbConnection dbcon;
dbcon = new SqliteConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd;
dbcmd = dbcon.CreateCommand();
dbcmd.Connection = dbcon;
string sql = "CREATE TABLE test (nummer int)";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
sql = "INSERT INTO test VALUES (12)";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
sql = "SELECT nummer FROM test";
dbcmd.CommandText = sql;
IDataReader reader;
reader = dbcmd.ExecuteReader();
while (reader.Read())
{
int nummer = reader.GetInt32(0);
Console.WriteLine(nummer);
}
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}
}

Thanks in advance,

Rick van Lieshout


Nov 15 '05 #3
"Mark Fitzpatrick" <ma******@fitzme.com> wrote in
news:OB**************@tk2msftngp13.phx.gbl:
Don't create the reader on one line then set it the next. Instead you
create it as a returned result on the same line:

don't do:
IDataReader reader;
reader = dbcmd.ExecuteReader();

Do this instead:
IDataReader reader = dbcmd.ExecuteReader();


and why would that help? The first of his 2 lines declares an
identifier in the local stackframe. The second line puts the reference
address of the reader object as the value of the identifier. Same as your
line.

To Rick: as people on GoT already suggested, it might be a bug in
SQLite.

FB

--
Solutions Design : http://www.sd.nl
My open source .NET Software : http://www.sd.nl/software
My .NET Blog : http://weblogs.asp.net/FBouma
-------------------------------------------------------------------------
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: John Salerno | last post by:
I've been looking around and reading, and I have a few more questions about SQLite in particular, as it relates to Python. 1. What is the current module to use for sqlite? sqlite3? or is that not...
4
by: Jim Carlock | last post by:
I added the following lines to PHP.INI. extension=php_pdo.dll extension=php_pdo_sqlite.dll extension=php_sqlite.dll specifically in that order. I noticed the extensions getting loaded are...
1
by: Rustom Mody | last post by:
I was trying to follow the sqlalchemy tutorial on my debian etch box and got stuck with installation. Any help/pointers will be welcome. First after installing sqlalchemy needed some sqlite...
4
by: mahdaeng | last post by:
I have a little Windows application written in C# with a SQLite back- end. I'm using the System.Data.SQLite provider. One of the features the application provides is a database back-up, which...
10
by: Luigi | last post by:
Hello all! I'm a newbie in PHP. I have written a short script that tries to update a SQLite database with the user data. It is pretty simple, something like this: <?php $sqlite =...
3
by: Daniel Fetchinson | last post by:
Does Python 2.5.2's embedded SQLite support full text searching? Sqlite itself is not distributed with python. Only a python db api compliant wrapper is part of the python stdlib and as such it...
0
by: Joe Goldthwaite | last post by:
Thanks Guilherme. That helped. I guess I was thinking that pysqlite would automatically come with some version of sqlite. The fact that it doesn't is what was causing me to get the strange...
2
by: flagos | last post by:
Hi to all! Any of you know if it's possible to use the Cairo graphics library in a WIN32 c# application? I know there is a binding made for Mono but my app will run on win32 so obviously I wont...
20
by: timotoole | last post by:
Hi all, On a (sun) webserver that I use, there is python 2.5.1 installed. I'd like to use sqlite3 with this, however sqlite3 is not installed on the webserver. If I were able to compile sqlite...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.