更多TextBox中的查询结果 [英] Results of query in more TextBox

查看:64
本文介绍了更多TextBox中的查询结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的解决方案是c#Windows应用程序,数据库是MySql.
我需要在表单上的每个TextBoxes中显示"Select"语句的结果,但是,我如何编写代码,表单上的TextBox仅由查询返回给我的第一条记录填充.
我想残酷地解释一下:表单上的每个TextBox都必须像一行记录一样填充...我希望我的英语很清楚...

[由编辑者移至此处]
我有2个主要形式的TextBoxes,TextBox1用于条形码阅读器的数据输入.
在验证textbox1的事件时,运行数据库查询以填充TextXoxes2,然后再次查询textbox3/4 ..textbox10/11.
在插入结束时,我保存了所有内容并关闭了应用程序.
现在,我的大问题是,在应用程序加载事件时,我将加载之前保存的先前数据.
我接受任何建议...

非常感谢

Hi,
my solution is a c# Windows Application and the DataBase is MySql.
I need to display in every TextBoxes on the form the results of the "Select" statement but, how I have write the code, the TextBoxes on the form are populated only by the first record that the query return to me.
I would like to explain brutally:every TextBox on the form must be like a line of record filled...I hope that my English is clear...

[Moved here by Editor]
I have 2 TextBoxes in main form, the TextBox1 it''s used for data entry by barcode reader.
On Validating event of the textbox1, goes run a database query that fill TextXoxes2,and so again for textbox3/4 ..textbox10/11.
At the end of insert, I save all and I close the application.
Now, my big problem, I would to load, at load event of application, the previous data that I have saved before.
I accept any suggest...

Thank''s a lot

推荐答案

"Don''t"是简单的答案.
您可以这样做,但这将是手动过程,如果文本框数量的记录太多或太少,就会出现问题.
如果不使用以表格格式显示数据的DataGridView,您会好得多,这更适用于原始数据的行和列性质.
"Don''t" is the simple answer.
You could do it, but it would be a manual process, and there would be problems if there are either too many records for the number of textboxes, or too few.
You would be much, much better off not using a DataGridView which would display the data in a table format, more applicable to the row and column nature of the original data. It''s also a lot easier!


你好,

好问题!
TextBox如何显示字段集合?!
如果TextBox绑定到集合,则只能显示一个字段.

但是您可以计划另一个属性(例如"SelectedField"),它不是一个集合,并将TextBoxes绑定到该属性.



===============================

并且:
如果要加载以前保存的数据.然后在数据库中创建一个表(例如:DataLog):


ID
User_ID
SavedDateTime

该表必须与主数据表(1到1)相关,ID到ID

如果只有一个用户,则忽略User_ID

好的,您可以查询用户输入的最后一个数据.在OnLoad或每次.
Hello,

Good question!
How can a TextBox show a collection of fields?!
TextBox can only show one field if it binds to a collection.

But you could plan for another property like "SelectedField" that is not a collection and bind the TextBoxes to it.



================================

And:
If you want to load the previous data that you have saved. Then Create a table in database (for Example: DataLog):


ID
User_ID
SavedDateTime

This table must relate to the main data table (1 to 1) ID to ID

If you have only one User then Ignore User_ID

Ok you can query for the last Data that the user has entered. on OnLoad or every time.

var data = MyDataCollection.OrderByDescending(d=>(d.DataLog.SavedDateTime && d.DataLog.User_ID == myID));
if(data.Count()>0)
 var selectedData = data.First();


坦克以作答,
我会更好地解释我的必要性.
我有2个主要形式的文本框,TextBox1用于条形码阅读器的数据输入.
在验证textbox1的事件时,运行数据库查询以填充textboxes2,然后再次查询textbox3/4 ..textbox10/11.
在插入结束时,我保存了所有内容,然后关闭了该应用程序.
现在,我的大问题是,在应用程序加载事件时,我将加载之前保存的先前数据.
我接受任何建议...谢谢

--------------------------------------------------
非常感谢您的答复,但在C#中,您的水平比我高....

我不明白您的代码段...您是否可以针对要填充的TextBox插入更多代码行?

在VS2010中,我在TextBox上看不到任何SelectedField属性...

再次感谢...
Tank''s for replies,
I would to explain better my necessity.
I have 2 textboxes in main form , the TextBox1 it''s used for data entry by barcode reader.
On Validating event of the textbox1, goes run a database query that fill textboxes2,and so again for textbox3/4 ..textbox10/11.
At the end of insert, I save all and I close the app.
Now, my big problem , I would to load, at load event of application, the previous data that I have saved before.
I accept any suggest...Thank''s

--------------------------------------------------
I appreciate your reply, but you''re in more elevate level than me in C#....

I don''t understand your snippet...may you insert more code lines regarding the TextBox that there be filled?

In VS2010 I don''t see any SelectedField properties on TextBox...

Thank''s again...


这篇关于更多TextBox中的查询结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆