Raspberry Pi 点击触摸屏按钮将数据发送到数据库
Raspberry Pi touch screen button on click sends data to database
我正在使用网站上的代码 (https://www.hackster.io/dotMorten/windowsiottouch-44af19)
显示我的触摸屏。
我试过的每个 sqlite 代码都不起作用。
我什至不能使用参考:'using microsoft.data'
我无法将我的 UWP 连接到 database.I 遵循了许多教程并尝试了 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();
}
星号线上 "open" 的红线,虽然我有参考
SQLite 是一个嵌入式 SQL 数据库引擎。与大多数其他 SQL 数据库不同,SQLite 没有单独的服务器进程。 SQLite直接读写普通磁盘files.From你提供的代码,
SQLiteConnection sqlite_conn = new SQLiteConnection("Data Source=App_Data/Simplicity.mdf;");
好像数据库不是SQLite而是SQL服务器数据库file.You可以参考这个sample about Sqlite support in Windows 10 UWP, or you can refer to this guide说明如何使用SQL ite 在您设备上的轻型数据库中存储和检索数据。
我正在使用网站上的代码 (https://www.hackster.io/dotMorten/windowsiottouch-44af19) 显示我的触摸屏。
我试过的每个 sqlite 代码都不起作用。 我什至不能使用参考:'using microsoft.data'
我无法将我的 UWP 连接到 database.I 遵循了许多教程并尝试了 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();
}
星号线上 "open" 的红线,虽然我有参考
SQLite 是一个嵌入式 SQL 数据库引擎。与大多数其他 SQL 数据库不同,SQLite 没有单独的服务器进程。 SQLite直接读写普通磁盘files.From你提供的代码,
SQLiteConnection sqlite_conn = new SQLiteConnection("Data Source=App_Data/Simplicity.mdf;");
好像数据库不是SQLite而是SQL服务器数据库file.You可以参考这个sample about Sqlite support in Windows 10 UWP, or you can refer to this guide说明如何使用SQL ite 在您设备上的轻型数据库中存储和检索数据。