Question
I am building an application on C# using SQLite, I get an error, couldn't fix it, I am a beginner in C# this is the
I am building an application on C# using SQLite, I get an error, couldn't fix it, I am a beginner in C#
this is the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using SQLite;
using Xamarin.Forms;
namespace FormsMenu
{
public class ContactListDB
{
private SQLiteConnection _connection;
public ContactListDB()
{
_connection = DependencyService.Get
_connection.CreateTable
Debug.WriteLine("Connection String: " + _connection.ToString());
}
public IEnumerable
{
return _connection.Query
}
public int Count()
{
return Convert.ToInt32(_connection.Table
}
public Contact GetTheContact(int id)
{
return _connection.Table
}
public void AddContact(string fName, string lName, string type)
{
var newContact = new Contact(fName, lName, type);
string updateTheQuery = string.Format("INSERT INTO Contacts (FirstName, LastName, ContactType, FullName) VALUES ('{0}', '{1}', '{2}'. '{3}'", newContact.FirstName, newContact.LastName, newContact.ContactType, newContact.FullName);
_connection.Execute(updateTheQuery);
}
public void DeleteContact(int id)
{
_connection.Delete
}
public void updateContact(string fName, string lName, string type, int id)
{
string updateTheQuery = string.Format("UPDATE Contacts SET FirstName='{0}', LastName='{1}', ContactType='{2}', FullName='{0} {1}' WHERE ID={3}", fName, lName, type, id);
_connection.Execute(updateTheQuery);
}
}
}
using System; using System.Collections.Generic; using System.Linq; using System. Text; 1 2 4 5 using System.Threading.Tasks; using System.Diagnostic using SQLite; using Xamarin.Forms; 9 namespace FormsMenu 12 public class ContactListDB private SQLiteConnection _connection; public ContactListDB() 17 connection DependencyService . Get ISQLite>().GetConnection(); connection. CreateTable
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started