将表单字段插入数据库 [英] Inserting form fields to database

查看:117
本文介绍了将表单字段插入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我被困在设计一个包含许多唯一字段的表格(财政年度)的情况下.我想知道我如何将这些字段插入数据库,因为使用预处理语句将意味着我的插入语句会无休止地(因为字段是60).表单模式是垂直排列的月份和5个标题(水平排列的).由于所有字段都是唯一的,因此使用数组的选项将不起作用.

任何帮助将不胜感激.
在此先谢谢您

Hi All,
I am stuck in a situation wherein i am given to design a form(financial year) which contains many unique fields.I want to know how do i insert these many fields to database as using prepared statement would mean my Insert statement would go endless(as the fields are 60).The form pattern is i have months vertically arranged and 5 headers (horizontally arranged).Also an option of using an array wont work since all the fields are unique..

Any help would be highly appreciated.
Thanks in advance

推荐答案

您可以创建一个数据传输对象,该对象将是一个包含所有字段作为属性的类.您可以创建数据传输对象的列表,并在其中填充表单数据并发送.

如果数据量很大,则最好使用存储过程来插入数据.对于存储过程,您可以将所有数据作为XML传递给存储过程,而不必使用准备语句,这比准备语句要快得多.

希望此建议对您有帮助.
You can create a Data Transfer Object, which will be a class with all your fields as properties. You can create a List of your Data Transfer Object fill it with your form data and send it.

You better use to a stored procedure to Insert your Data, if the Data Volume is big. In the case of Stored Procedure you can pass all your Data as XML to the Stored Procedure instead of using a Prepared Statement, which will be much faster than a Prepared Statement.

Hope this advice helps.


这篇关于将表单字段插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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