0
votes

I found a SQLite implementation for Xbox 360 started by Kevin Gadd when on MSDN forums but their was a google C#-SQLite implementation DLL that was made that he used. I just wish to know how the API works because the original website where they ported it to c# here: http://code.google.com/p/csharp-sqlite/ doesn't list how they changed the API but it does say most of the basic commands or at least from some comments/description that's what I got.

The DLL from above does work on Xbox 360 XNA because i tried it. My main goals so its easier to see where im going with this are:

  1. Create a simple database on Xbox 360 with 2-3 tables as a test (maybe on Windows and then put database in content section so it deploys with rest of game to Xbox 360).
  2. Send data to those tables in test scenario maybe using insert or update but I don't know SQLite commands like MySQL and MS-SQL in .NET.
  3. Do garbage collection

If at all you can ignore everything else and just do the 3 things above but if I can do #1 + #2 (basic SQLite skills) I will find someone else to help me with #3 because usage would be most of the battle and then I could get someone to help me with the rest.

Im worried about learning how to use SQLite for c# can someone relay me the differences between SQl Server and SQLite when programming in code and limitations i should be worried about is my only big question. Edit: jsut wish to do 1 + 2 and rest i dont care about.

2
You should ask one question at a time. That's much easier to answer.MPelletier
Just looking for how to use sqlite with c# and xna on the Xbox but iam worried about garbage collectionjeffery
I know the sql queries but I dont know the c# command to execute the sql query with the above library link.jeffery

2 Answers

0
votes

Your big problem here is you can't write to your applications install folder on Xbox. You have to use the save system. You could copy your sqlite db file into a new save on creation.

I'd avoid keeping the connection open for a long time and just use it to serialize/deserialize the data. You'll probably have less of a headache just using normal xml serialization see http://msdn.microsoft.com/en-us/library/system.xml.serialization.aspx It's actually simpler that doing what you're trying to do.

A custom binary format should be smaller, but that's more complicated. Look into how the content serializer works for xml => xnb serialization.

0
votes

I'm not sure if the Xbox 360 will actually support SQLite. I don't think you're supposed to even be using SQL for XNA game projects on anything other than windows. They supply built-in memory management and XML parsers for that.

As for how to attach to a SQLite database, you need to include your SQLite DLL into your projects references.

After that, add the following to your using statements.

using System.Data;
using System.Data.SQLite;
using System.IO;

To link to your database and query data / issue a SQL Command, use the following.

SQLiteConnection sqlCon = new SQLiteConnection("Data Source=<pathtodbfile>;Version=3;New=True;Compress=False;");

sqlCon.Open();
SQLiteCommand cmd = sqlCon.CreateCommand();

SQLiteDataAdapter db = new SQLiteDataAdapter("<your SQL Query Here>", sqlCon);

DataSet ds = new DataSet();
ds.Reset();

db.Fill(ds);

Then you can access the data it loaded via.

ds.Tables[0]; <-- Your data set can store many tables, but for a query, it will load a table of your queried data for you into the first index. This is why I did a ds.Reset(), because you may decide to reuse a dataset somewhere.

That will work with C# in Windows. If you have all your references and using statements done correctly, this should also work in an XNA project.

As I said before though, I'm not sure if ANY of this works on an Xbox 360 machine.