[英]how to change Label text to last value from MySql database?
So i got a database senzor with user senzor and pass password the database looks like this database screen 所以我用用户senzor得到了一个数据库senzor并通过了密码,数据库看起来像这个数据库屏幕
i want to display last value from "temp" in a text label in c# program when i click a "REFRESH" button. 当我单击“刷新”按钮时,我想在c#程序的文本标签中显示“ temp”的最后一个值。 i`m using visual studio 2013 C# for the program.
我使用Visual Studio 2013 C#编写程序。
PS the text label will automaticly change value when i click the REFRESH button and will remain unchanged untill i press the REFRESH button again. PS,当我单击“刷新”按钮时,文本标签将自动更改值,并且将保持不变,直到再次按下“刷新”按钮。
thanks in advance , 提前致谢 ,
Johnny M 约翰尼M
Order descending, then use the limit to return the last row -- now in the first position! 降序排列,然后使用限制返回最后一行-现在位于第一个位置!
String query = @"SELECT temp
FROM TableName
ORDER BY Id DESC
LIMIT 1";
string connString = "Server=localhost; Database=myDatabaseName;
Trusted_Connection=Yes";
SQLiteConnection connection = new SQLiteConnection(connString);
SQLiteDataAdapter da = new SQLiteDataAdapter(query, connection);
DataSet ds = new DataSet();
Do your table mappings if any. 进行表映射(如果有)。 And then call
da.Fill(ds, "issuedBooks");
然后调用
da.Fill(ds, "issuedBooks");
Label.Text = ds;
you can use this code inside button "REFRESH" 您可以在按钮“刷新”中使用此代码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.