如何使用.net和sql运行动态数据库查询 [英] How to run dynamic database query using .net and sql

查看:219
本文介绍了如何使用.net和sql运行动态数据库查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,我需要一些帮助..



i有500多个领域的巨大形式..



我不想输入500+时间插入选项是他们帮助我实现这个想法的一种方式:



- >用户得到这样的:

 -------------- 
姓名:| | < - 单项
--------------
--------------
国家:| |
| | < - 下拉
| |
--------------

其他详情:


[添加按钮]< - 这个按钮为表单添加2个字段,如

--------------- -------------- ----- ---------
| | | | | | [文字框]
| 1 | | 1.1 | | 1.1.1 |
--------------- -------------- --------------

[添加按钮]< - 添加上面的视图用户后再次获取一个新的添加按钮,将新字段添加到数据库。


现在在上面的场景中,当用户选择添加按钮并在屏幕上添加3个下拉菜单和1个文本框时。

当用户选择第一个下拉选项时,它会在1.1下拉列表中显示其相关子选项,然后当该用户的用户选择选项根据1.1下拉选择获得1.1.1选项时。

现在!!!用户只需将整数值或Alphabet值添加到TextBox即可。并且他获得了新的添加按钮和与上述相同的选项,直到用户想要提交表单。

一旦他提交了值,就应该转到数据库中的相应字段,或者它应该为它创建一个新的字段。我不知道如何做到这一点。

现在请进一步帮助我,因为我无法离开这里..

解决方案

添加新列在应用程序执行期间的表是一个维护问题并被认为是糟糕的设计(不包括例外)。



您的表设计应该以这种方式来适应变化。例如,您可以使用自联接来构建父子关系以满足此类情况。



要批量插入数据,您可以使用XML。查看此链接



将XML格式的数据插入SQL Server 2000 [ ^ ]



http://msdn.microsoft.com/en-us/library/aa258669(v = sql.80)的.aspx [ ^ ]

Hey guys, i need some help..

i have a huge form with 500+ fields..

I don't want to type 500+ time insert option is their a way to help me achieve my this idea:

-> User get a for like this:

        --------------
Name:  |              |       <-- Single Entry
        --------------
          --------------
Country: |              |
         |              |     <--  Dropdown
         |              |  
          --------------

Other Details:


[Add Button]   <--  This button adds 2 fields to the form like

 ---------------        --------------      --------------
|               |      |              |    |              |       [ Text Box ]    
|  1            |      |  1.1         |    | 1.1.1        |
 ---------------        --------------      --------------

[Add Button]   <-- After adding above view user again get a new Add button to add new field to database.


Now in above scene, when user select Add button and that adds 3 dropdown to screen and 1 text box to screen.

When user select 1st dropdown option , it shows its related child options in 1.1 dropdown then when user select option for that user gets 1.1.1 options visible based on 1.1 dropdown selection.

Now !!!  User simply add the integer value or Alphabet value to the TextBox. And he gets new add button and  same options as above described until user want to submit the form.

Once he submit the values should go to the respective fields in database or it should create a new fields for it.. I don't know how to make that way .

Now please help me further as i got no way out here..

解决方案

Adding new columns in a table during application execution is a maintenance issue and considered bad design (excluding exceptions).

Your table design should be in such way to accomodate the changes. For example you can build parent child relationships using self joins to cater such cases.

For inserting data in bulk you can use XML. Check this link

Inserting XML formatted data into SQL Server 2000[^]

http://msdn.microsoft.com/en-us/library/aa258669(v=sql.80).aspx[^]


这篇关于如何使用.net和sql运行动态数据库查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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