如何编写C#UI以从数据库中提取预先填充的数据 [英] How do I code C# UI to pull pre-populated data from database

查看:69
本文介绍了如何编写C#UI以从数据库中提取预先填充的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C#的新手。我有一个UI需要从数据库中检查可用时间并显示是否仍然可用。如果日期不可用,用户应该无法从用户界面中选择它。



我尝试了什么:



我创建了3个表。

- 预订表

-临时日期和时间表

- 主要日期和时间表

我创建了一个存储过程使用临时表预先填充预订的日期,时间和可用地点。我还创建了一个存储过程来提交预订和更新日期,时间,从Web表单提交记录时的可用位置



我需要一个合适的c#代码可以从我的数据库表和存储过程中读取数据并仅显示可用的日期,时间和点。



我们将非常感谢您的帮助。



谢谢,

Hetty

I am new to C#. I have a UI that needs to check available time from the database and display if still available. If the date is not available, a user should not be able to select it from the UI.

What I have tried:

I created 3 tables.
- reservation table
-Temporary date and time table
- Main date and time table
I created a stored procedure to pre-populate date, time and available spot for a reservation using a temporary table. I also created a stored procedure to submit a reservation and update date,time, available spot when a record is submitted from the web form

I need a proper c# code that can read the data from my database tables and stored procedure and display only available date, time and spots.

Your help will be greatly appreciated.

Thank you,
Hetty

推荐答案

这不是我们真正可以回答的问题一个小文本框:您没有向我们提供任何UI指南,例如您计划使用的控件,我怀疑这至少部分是因为您不知道您的UI应该是什么样的,或者它应该如何工作任何细节。



从数据库中检索数据很简单,无论源是存储过程还是直接表,都使用相同的机制和类 - 但是类的细节取决于您使用的数据库系统:MyS ql使用MySqlConnection,MySqlCommand等,SQL Server使用SqlConnection,SqlCommand,... - 和Wold使用OledbConnection,OledbCommand,...

首先,看看文档中的适用于特定数据库系统的Command和DataAdapter类 - MSDN是一个良好的开端,通常包括示例代码。



当您对数据库进行排序时,请坐下来考虑UI详细信息:确定用户需要查看的内容,以及您希望他与您的应用程序进行交互的具体方式。运行概述规范,并通过计算出您想要使用的控件来开始将其细化为正确的设计文档。



那么你可以开始询问如何将两者连接在一起,但不是之前!
This isn't a question we can really answer in a little text box: you haven't given us any UI guides such as the controls you plan on using, and I suspect that is at least in part because you don't know what your UI should look like, or how it should work in any detail.

Retrieving data from a DB is simple, regardless of the source being a Stored Procedure or a table directly, the same mechanisms and classes are used - but the specifics of the classes depends on the database system you are using: MySql uses MySqlConnection, MySqlCommand, and so forth, SQL Server uses SqlConnection, SqlCommand, ... - and Access wold use OledbConnection, OledbCommand, ...
So first off, look at the documentation for the Command and DataAdapter classes for you specific database system - MSDN is a good start, and generally includes example code.

When you have DB's sorted, sit down and think about the UI in detail: work out what the user needs to see, and exactly how you want him to interact with your application. Run up a overview specification, and start refining that into a "proper" design document by working out what controls you want to use.

Then you can start asking how you connect the two together, but not before!


这篇关于如何编写C#UI以从数据库中提取预先填充的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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