如何插入记录插入一个按钮从数据库中日点击TODATE? [英] how to insert record into database on single button click from date to todate?
问题描述
我有三个文本框... TextBox1的1和TextBox和textbox3
I have three textbox ... textbox1 and textbox2 and textbox3
我想,当我选择日期在TextBox1中说,1 - 5月份,2011年至今在TextBox2中说30 2011年5月,并在文本框I型1,2,3,4,5
I want when I choose from date in textbox1 say 1-May-2011 and to date in textbox2 say 30-May-2011 and in textbox I type 1,2,3,4,5
我想在按钮点击...事件中的值将在数据库中entererd从1 - 5月 - 2011年30 May2011为:提到如下:
I want on button click ... event the values will be entererd in database from 1-May-2011 to 30-May2011 as : mentioned below :
DATABASE STRUCTURE
ID Date Items
1 1-May-2011 1,2,3,4,5
2 2-May-2011 1,2,3,4,5
3 3-May-2011 1,2,3,4,5
等等,直到30_may-2011
so on till 30_may-2011
记录将根据被插入在数据库中的日期和分别迄今为止在TextBox1中choosen 1和TextBox ...
Record will be inserted in database according to from date and to date choosen in textbox1 and textbox2 respectively ...
如何解决此问题?
推荐答案
如果它是你接受的解决方案,那么最简单的方法是构建插入的所有数据,然后将他们全部(它会引起一些刀片)。这是Ranhiru Cooray在他的回答也暗示 - 刚刚经历的所有日期迭代,构建每一行并调用插件为每个
If it is acceptable for your solution, then the easiest way is to construct all the data for insertion and then insert them all (it will cause a number of inserts). This is what Ranhiru Cooray has suggested in his answer - just iterate through all dates, construct each row and call insert for each of them.
但是,如果你想要一个DB调用做到这一点,那么我建议创建数据库的存储过程,它得到这3个参数,然后它里面执行插入 - 通过构建内部本身的插入行和执行他们每个人 - 仍保持在一个单一的数据库调用你的code或应用程序的范围
BUT, if you want to do it by one DB call, then I would suggest creating a stored procedure in database, which gets these 3 parameters and then executes inserts inside it - by constructing insertion rows inside itself and executing each of them - still remaining in bounds of a single database call for your code or application.
我希望这有助于!
这篇关于如何插入记录插入一个按钮从数据库中日点击TODATE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!