Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hii i need help to create a table in uwp with these item to store a data

                + data_0 + " INTEGER, "
                + data_1 + " INTEGER, "
                + data_3 + " INTEGER, "
                + "PRIMARY KEY(" + SITEINFO_SITEID + "))";

What I have tried:

i don't know how to create a class and what code should i need to give in it
Updated 27-Oct-22 20:16pm

UWP has nothing specific to do with database tables: it's a presentation format that isn't data related. That doesn't mean "you can't use a DB in a UWP app", just that it's irrelevant whether this is a UWP app or not - the DB code is the same.

So we can't help you: that looks like a valid SQL CREATE TABLE command, but we have no access to your db object or the execSQL method it contains - let alone any idea what else it supports as far as reading or writing data to the DB goes.

I'd suggest you go back to wherever you got that code from and start there - or better, find a book on C# and read the section(s) on database and good practices as there are a lot of potential problems you can give yourself if you don't know what you are doing. And whoever wrote that code clearly doesn't care too much about coding standards for his C# code, so his practices for DB's are likely to be just as suspect!
Share this answer
You did not specify what database you want to use, if you need only one data file per user you can use LiteDB[^]

An example from Getting Started - LiteDB :: A .NET embedded NoSQL database[^]:
// Create your POCO class entity
public class Customer
    public int Id { get; set; }
    public string Name { get; set; }
    public string[] Phones { get; set; }
    public bool IsActive { get; set; }

// Open database (or create if doesn't exist)
using(var db = new LiteDatabase(@"C:\Temp\MyData.db"))
    // Get a collection (or create, if doesn't exist)
    var col = db.GetCollection<Customer>("customers");

    // Create your new customer instance
    var customer = new Customer
        Name = "John Doe", 
        Phones = new string[] { "8000-0000", "9000-0000" }, 
        IsActive = true
    // Insert new customer document (Id will be auto-incremented)
    // Update a document inside a collection
    customer.Name = "Jane Doe";
    // Index document using document Name property
    col.EnsureIndex(x => x.Name);
    // Use LINQ to query documents (filter, sort, transform)
    var results = col.Query()
        .Where(x => x.Name.StartsWith("J"))
        .OrderBy(x => x.Name)
        .Select(x => new { x.Name, NameUpper = x.Name.ToUpper() })

    // Let's create an index in phone numbers (using expression). It's a multikey index
    col.EnsureIndex(x => x.Phones); 

    // and now we can query phones
    var r = col.FindOne(x => x.Phones.Contains("8888-5555"));

Btw: LiteDB also supports Portable UWP and Xamarin iOS/Android applications.
Share this answer
Ailiseu Brigitta 28-Oct-22 2:54am    
thank you RickZeeland

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900