简体   繁体   English

如何将标签文本更改为MySql数据库中的最后一个值?

[英]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.

相关问题 C#如何显示从Mysql数据库到标签的值? - C# How to display a value from Mysql database to a label? 使用数据库中的文本更改标签的值 - Changing the value of a label with text from a database 如何查找转发器的标签值(数据库列)和更改repeater_ItemDataBound事件上的文本 - How to find label value (database coloumn) of repeater and change text on repeater_ItemDataBound event 如何从另一个表格更改标签的文本? - How to change the text of Label from another Form? 如何从数据库获取价值到标签? - How to get value from database to a label? 从数据库插入数据后,如何更改标签的值? - How do I change the value of a label after inserting a data from the Database? 每次更改组合框值时,如何从数据库中计算数字并将其显示给标签? - How could I compute the number from the database and show it to the Label everytime I change the combo box value? 如何从另一个在Xamarin IOS中添加UITabBarController的控制器更改标签的文本值 - How to change the text value of label from another controller which added UITabBarController in Xamarin IOS onmouseover根据数据库中的值更改文本 - onmouseover change text based on value from database 如何根据所选的comboBox值更改标签文本? - How to change label text according to the comboBox value selected?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM