Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# sqlite query

public List<string> GetUsers()
{
	// Init return list
    List<string> users = new List<string>();

	// Set the path to sqlite file
    string solutionPath = Environment.CurrentDirectory;
	string dbPath = Path.Combine(solutionPath, "db.sqlite3");    

    SQLiteConnection connection = new SQLiteConnection(solutionPath);
    connect.Open();

	// Construct sql query
    SQLiteCommand command = connection.CreateCommand();
    command.CommandText = @"SELECT username FROM tableUsers";
    command.CommandType = CommandType.Text;

    SQLiteDataReader reader = command.ExecuteReader();

	// reader is treated like a array so call 
    while (reader.Read())
    	users.Add(Convert.ToString(reader["username"]));

	// Clean up no longer needed connection
	connection.Close();

    return users;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity getcomponent not working on ui 
Csharp :: Find an item in a list by LINQ 
Csharp :: hashing a file in C# 
Csharp :: button size xamarin 
Csharp :: c# to binary 
Csharp :: how to make a car in unity 
Csharp :: how to use distinct in linq query in c# 
Csharp :: c# list grouping 
Csharp :: enum element count C# 
Csharp :: List string to file C# 
Csharp :: how to make a mouse down condition in C# 
Csharp :: palindrome number c# 
Csharp :: cannot convert from string to type T 
Csharp :: c# array 
Csharp :: c# making a folder 
Csharp :: c# list tuple 
Csharp :: c# bytes to image 
Csharp :: add item to list c# 
Csharp :: how to convert pdfdocument to binary in c# 
Csharp :: unity c# foreach 
Csharp :: c# jobject to string 
Csharp :: unity rotate direction by angle 
Csharp :: ienumerable foreach 
Csharp :: how to make dictionary c# 
Csharp :: get attribute value of xml element c# 
Csharp :: what is type unity 
Csharp :: No migrations configuration type was found in the assembly 
Csharp :: LINQ query to select top 5 
Csharp :: how to get specific length of row in matrix c# 
Csharp :: recursive reverse linked list 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =