• 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
0
Question by Gilead7 · Feb 20, 2016 at 06:29 PM · c#listsqlitesort

SQLite Sort and or List Sort

I'm working on an android app in unity.(C#) I have an sqlite database using the SQLiter asset downloaded from the asset store.

It works fine, but prints out the data as entered. So if you delete something and put it back in, it places it at the very end rather than where it used to be. I've tried to have it sort, but neither way seems to be recognized.

 public void ShowAllEquipment()
 {
     for(int i = 0; i< Equipment.Count; i++)
     {
 
         GameObject beObj = Instantiate(EquipmentPrefab);
         BandEquipment tmpEquipment = Equipment[i];
         beObj.GetComponent<EquipmentScript>().DisplayEquipment(tmpEquipment.EquipmentID, tmpEquipment.EquipmentDescription);
         beObj.transform.SetParent(Displayparent); 
 
     }
     Equipment.Sort(SortByEquipmentID); This gives an error that it doesn't know what SortByxxxx is.
 
 }
 
 public void GetAllEquipment()
 {
     Equipment.Clear();
     mConnection.Open();
     mSQLString = "SELECT * FROM " + SQL_TABLE_EQUIPMENT ORDER BY EquipmentID;                  Here it give me a red squiggle on ORDER BY
     mCommand.CommandText = mSQLString;
     mCommand.ExecuteNonQuery();       
     mReader = mCommand.ExecuteReader();
 
     while (mReader.Read())
     {
         Equipment.Add(new Equipment(mReader.GetString(0), 
                                     mReader.GetString(1)));
 
         Debug.Log(mReader.GetString(0) + mReader.GetString(1));
     }
 
     mReader.Close();
     mConnection.Close();
 }


  1. What is the best way to do this?

  2. Where does it need to be done?

  3. Any suggestions?

Thanks all!

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by jgodfrey · Feb 20, 2016 at 09:51 PM

For starters, this...

 mSQLString = "SELECT * FROM " + SQL_TABLE_EQUIPMENT ORDER BY EquipmentID;  

Should be...

 mSQLString = "SELECT * FROM " + SQL_TABLE_EQUIPMENT + " ORDER BY " + EquipmentID;  

Since the "ORDER BY" clause is just a static portion of the final string - not a variable reference.

Comment
Add comment · 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 Gilead7 · Feb 21, 2016 at 07:31 PM 0
Share

Ahh! Thanks! I thought it must be something to do with quotes.

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

98 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Return List from Singleton 1 Answer

How to create endless board game path 2 Answers

How to alphabetically sort your List? 2 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