从多个aspx网页将数据插入SQL数据库表

时间:2022-02-08 03:45:44

I am currently have an asp.net web site through visual studio that contains three .aspx pages. Each .aspx page has simple label and text box fields in it. There is a button in each web aspx page also that redirects to the second and third page as well as a submit button at the end of the third page. Also behind the buttons there is an sql command/ query that Inserts the input from the textboxes into an sql database. I have one table in the database that I want input from all three pages. When I tried to do this the input from the first page correctly stayed in the first row. Then the input from the second page made its own second row and so on... I am also using a INSERT statement for each web aspx page. I have a picture below of what the database looks like... how can I get all the input into one row

我目前通过visual studio有一个asp.net网站,其中包含三个.aspx页面。每个.aspx页面都包含简单的标签和文本框字段。每个Web aspx页面中都有一个按钮,可以重定向到第二页和第三页,以及第三页末尾的提交按钮。按钮后面还有一个sql命令/查询,它将文本框中的输入插入到sql数据库中。我在数据库中有一个表,我希望从这三个页面输入。当我尝试这样做时,第一页的输入正确地保留在第一行。然后第二页的输入创建了自己的第二行,依此类推......我也在为每个web aspx页面使用INSERT语句。我在下面有一张数据库看起来像什么的图片......我怎样才能将所有输入都放到一行中

2 个解决方案

#1


0  

With your current configuration you'll need an update statement instead of an insert statement on the subsequent pages.

使用当前配置,您需要在后续页面上使用update语句而不是insert语句。

You could also do something like session variables and just insert after you've collected all the information.

您还可以执行类似会话变量的操作,并在收集完所有信息后插入。

#2


0  

If you want to get it into one row, you need to do one INSERT statement and the rest should be UPDATE statements. Each and every INSERT statement will create a new row in the database.

如果要将其放入一行,则需要执行一个INSERT语句,其余的应该是UPDATE语句。每个INSERT语句都将在数据库中创建一个新行。

When trying to UPDATE a row, make sure you add something like WHERE ID = x, so you only update the one row.

尝试更新行时,请确保添加WHERE ID = x之类的内容,以便只更新一行。

#1


0  

With your current configuration you'll need an update statement instead of an insert statement on the subsequent pages.

使用当前配置,您需要在后续页面上使用update语句而不是insert语句。

You could also do something like session variables and just insert after you've collected all the information.

您还可以执行类似会话变量的操作,并在收集完所有信息后插入。

#2


0  

If you want to get it into one row, you need to do one INSERT statement and the rest should be UPDATE statements. Each and every INSERT statement will create a new row in the database.

如果要将其放入一行,则需要执行一个INSERT语句,其余的应该是UPDATE语句。每个INSERT语句都将在数据库中创建一个新行。

When trying to UPDATE a row, make sure you add something like WHERE ID = x, so you only update the one row.

尝试更新行时,请确保添加WHERE ID = x之类的内容,以便只更新一行。