我正在使用网站上的代码(https://www.hackster.io/dotMorten/windowsiottouch-44af19) 显示我的触摸屏。
我试过的每个sqlite代码都不起作用。 我甚至无法使用引用:'using microsoft.data'
我无法将我的UWP连接到数据库。我遵循了许多教程并尝试了nuget包,但它不起作用。
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using System.Data;
using TouchPanels.Devices;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Automation.Peers;
using Windows.UI.Xaml.Automation.Provider;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using SQLite;
using SQLitePCL;
// The Blank Page item template is documented at
http://go.microsoft.com/fwlink/?LinkId=234238
namespace WindowsIoT.TouchSample
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a
Frame.
/// </summary>
///
public sealed partial class ManualUnlock : Page
{
//Please help change the database constring
// string connStr = @"Server=myServerName\myInstanceName;" +"Initial
Catalog=myDataBase;Integrated Security=True;";
//SqlConnection conn = new SqlConnection(connStr);
//conn.Open();
private SQLiteConnection sql_con;
private SQLiteCommand sql_cmd;
const string CalibrationFilename = "TSC2046";
private Tsc2046 tsc2046;
private TouchPanels.TouchProcessor processor;
private Point lastPosition = new Point(double.NaN, double.NaN);
public ManualUnlock()
{
this.InitializeComponent();
}
private void page_loaded(object sender, RoutedEventArgs e)
{
//write logic here
string tempcode = NumGen();
txtOTP.Text = tempcode;
Stopwatch timer = new Stopwatch();
timer.Start();
while (timer.Elapsed.TotalSeconds < 120)
{
using (sql_con)
{
// create a new database connection:
SQLiteConnection sqlite_conn =
new SQLiteConnection("Data Source=App_Data/Simplicity.mdf;");
// open the connection:
****************** sqlite_conn.Open();
sqlite_cmd = sqlite_conn.CreateCommand();
sqlite_cmd.CommandText = "SELECT * FROM account WHERE OTP =@otp";
// The SQLiteDataReader allows us to run through each row per loop
while (sqlite_datareader.Read()) // Read() returns true if there is still a result line to read
{
// Print out the content of the text field:
/*Sends message to database saying authenticated*/
}
}
}
timer.Stop();
}
星号线上“打开”的红线虽然我有参考
答案 0 :(得分:0)