• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Matt 6 · Feb 01, 2011 at 04:58 PM · databasestandalonesqlite

Issue running standalone using SQLite

We're working on a game that needs access to a SQLite .db file. We can't use PlayerPrefs so we're sticking with the SQLite solution. The problem that we are running into is that it works in the editor but we get the following debug crash when we try to load the .db in a stand alone player.

ArgumentOutOfRangeException: Argument is out of range. Parameter name: options at System.Text.RegularExpressions.Regex.validate_options (RegexOptions options) [0x00000] in :0 at System.Text.RegularExpressions.Regex..ctor (System.String pattern, RegexOptions options) [0x00000] in :0 at DbLinq.Vendor.Implementation.SqlProvider..cctor () [0x00000] in :0 Rethrow as TypeInitializationException: An exception was thrown by the type initializer for DbLinq.Vendor.Implementation.SqlProvider at DbLinq.Sqlite.SqliteSqlProvider..ctor () [0x00000] in :0 at DbLinq.Sqlite.SqliteVendor..ctor () [0x00000] in :0 at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (object,object[],System.Exception&) at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in :0 at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in :0 at System.Activator.CreateInstance (System.Type type) [0x00000] in :0 at DbLinq.Data.Linq.DataContext.GetVendor (System.String& connectionString) [0x00000] in :0 at DbLinq.Data.Linq.DataContext..ctor (System.String connectionString) [0x00000] in :0 at ContentManager.LoadDatabase (System.String sFileName, System.String sGameID, System.String sEnableFlags, System.String sDisableFlags) [0x00000] in :0 at BoardAttributes.Start () [0x00000] in :0

Our LoadDatabase function takes a string and we're passing it: ContentMan.LoadDatabase(@"C:\Content\2010\GameContent.db");

Our ContentMan then attempts to load the .db using the following code

    Table<ContentFilesTable> FilesTable;
    Table<FileTagsTable> TagsTable;
    SQLiteConnectionStringBuilder csb = new SQLiteConnectionStringBuilder();
    csb.Add("data source", sFileName);
    csb.Add("DbLinqProvider", "sqlite");
    SQLiteConnection connection = new SQLiteConnection(csb.ConnectionString);
    DataBase = new DataContext(connection);
    FilesTable = DataBase.GetTable<ContentFilesTable>();
    TagsTable = DataBase.GetTable<FileTagsTable>();
    //Grab the indexs with only the gameID we want
    var query = from n in TagsTable where n.tags.Contains("test") == true select n;
    List<FileTagsTable> MyList = query.ToList();

We're at a loss of why t$$anonymous$$s successfully works in the editor and not at runtime, we're only basically just shotgunning ideas on how to fix it so any and all suggestions are welcome. Thanks!

Comment

People who like this

0 Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Feb 01, 2011 at 06:41 PM 0
Share

Did you copied your database file into the data folder of your build? because a SQLite db file is not an asset that unity recognise and it won't be included in the build (like every asset that isn't referenced by anything). And make sure the path is correct for your build, i guess you use a relative path?

avatar image yoyo · Feb 01, 2011 at 06:48 PM 0
Share

The poster says he's loading from an absolute path on drive C: -- something he'll need to resolve for deployment, but should still work when running his build locally.

3 Replies

· Add your reply
  • Sort: 
avatar image

Answer by Oksana-Iashchuk · Sep 10, 2012 at 07:14 PM

http://u3d.as/content/orange-tree/sqlite-kit/3ka That is 100% managed code, full SQLite3 support, all platforms. No native dependencies.

Comment
ZorNiFieD

People who like this

1 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by yoyo · Feb 01, 2011 at 06:47 PM

Just trying to make head or tails of the error -- it's coming from the DataContext constructor, in a call to GetVendor.

Turns out source code for DataContext.cs is available online. It uses the vendor info in the connection string (or defaults in your case) to determine w$$anonymous$$ch assembly to load and what class to load from the assembly.

It appears the default assembly is DbLinq.SqlServer.dll -- perhaps t$$anonymous$$s Dll is missing from your standalone build? I'd review all the SQLite assemblies you're using and make sure they are all available in the standalone build.

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by Matt 6 · Feb 01, 2011 at 07:48 PM

So with just guessing and trying we came up with what the issue was. Turns out our problem was the player setting Api Compatibility Level being set to .NET 2.0 subset. A change to just .NET 2.0 resolved t$$anonymous$$s issue.

Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Alexis_87 · Aug 22, 2011 at 06:54 PM 0
Share

I'm trying to connect to a db.sqlite with basic unity and a IOS license to develop an app for the iphone 4. (I don't use Unity3d pro, I use the basic version).

When I try to build as IOS platform it return me an error, in play mode no error.

I put the dlls (System.Data and Mono.Data.SqliteClient)in the Assets/Plugins folder and the database in project_name folder. (I work con Mac, no Windows).

When I try to build as iOS platform it return me an error.

This is an extract of my code:

 import System.Data;
 import Mono.Data.SqliteClient;
 
 private var connectionString: String;
 private var dbcon : SqliteConnection; //the instantiation of this creates errors
 
 function Start () {
 
 connectionString = "URI=file:Assets/gate.sqlite";
 dbcon = new SqliteConnection ( connectionString );
 
 dbcon.Open();
 ...
 ...
 }

and the error:

  • Error building Player: SystemException: System.Net.Sockets are supported only on Unity iPhone Advanced. Referenced from assembly 'Mono.Data.Tds'. UnityEditor.HostView:OnGUI()

Thanks for the help

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

SQLite Transaction Update Problem on Android 0 Answers

Retrieving data from Sqlite database using Mono.Data.Sqlite 0 Answers

SQLite: updating integer with the value 1 to integer = integer + 1 results in 3 instead of 2 1 Answer

Can't make unity connect to SQLite database 1 Answer

Error... sqlite3_next_stmt 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges