从简单表单插入多个记录 [英] Inserting multiple records from simple form

查看:67
本文介绍了从简单表单插入多个记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有简单/基本的形式,但是很少有空洞。



这是表格的形式:



文本框1 - 静态

文本框2 - 静态

文本框3

文本框4

文本框5



文本框3-5将具有不同的值,但不是所有时间。我试图想办法告诉插入语句插入以下内容:



插入表value1,value2,value3 VALUES(Textbox1,Textbox2,Textbox3-5)



文本框3-5将决定何时添加新记录。如果4和5不为空,则将其作为新记录插入。



最好的方法是什么?



编辑:澄清一下,第3列将有来自文本框3,4,5。取决于表单的填写方式。



例如:

Textbox 1 = 101689(工作)

Textbox 2 = 07/15/2017(日期)

Textbox 3 = Jose

Textbox 4 = Tim

Textbox 5 = John



SQL表格:



ID工作日期EMP

1 101689 07/15/2017 Jose

2 101689 07/15/2017 Tim

3 101689 07/15/2017 John



希望这会有所帮助。



我尝试了什么:



尝试查看以下地点 电子插入>多种方式多个插入[ ^ ] [ ^ ]

So i have simple/basic form but there is little caviate.

This is how the form is:

Textbox 1 - static
Textbox 2 - static
Textbox 3
Textbox 4
Textbox 5

Textbox 3-5 will have different values but not all the time. I am trying to figure out a way to tell insert statement to insert following:

insert into table value1, value2, value3 VALUES(Textbox1, Textbox2, Textbox3-5)

Textbox 3-5 will decide when to add new record. If 4 and 5 are not empty itll insert as new record.

whats the best way to do this?

to clarify, column3 will have values from Textbox 3,4,5. Depending on how the form was filled out.

Example:
Textbox 1 = 101689 (job)
Textbox 2 = 07/15/2017 (date)
Textbox 3 = Jose
Textbox 4 = Tim
Textbox 5 = John

SQL Table:

ID job date EMP
1 101689 07/15/2017 Jose
2 101689 07/15/2017 Tim
3 101689 07/15/2017 John

Hope this helps.

What I have tried:

Tried looking into following place e-Inserts">Multiple Ways to do Multiple Inserts[^][^]

推荐答案

伪代码



pseudocode

job = textbox 1
date = textbox 2

if (textbox 3 not empty)
   insertrow (textbox3, job, date)

if (textbox 4 not empty)
   insertrow (textbox4, job, date)

if (textbox 5 not empty)
   insertrow (textbox5, job, date)





写一个insertrow 将名称,工作和日期作为参数并将其插入表中的函数。



write an "insertrow" function that takes the name, job and date as params and does an insert into the table.


这篇关于从简单表单插入多个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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