我想让我的一个表中的字段/变量转移到另一个表。变量是当前用户的用户 ID。两个表之间存在关系。当用户注册一个帐户时,会为他们创建一个 UserId。然后我希望用户能够存储关于他们自己的其他详细信息(存储在不同的表中)。这些项目应该是链接到用户的。如何让当前用户的 UserId 附加到他们提交给另一个表的详细信息?这些是 Visual Studio 为我创建的自行生成的 SQL 命令:
SelectCommand="SELECT [Bhousenum], [Bstreetname], [Bcity], [Bcounty], [Bcountry], [Dhousenum], [Dstreetname], [Dcity], [Dcounty], [Dcountry], [Dpostcode], [Bpostcode], [mobilenum], [credittype], [creditname], [creditnum], [securitycode], [creditexpiry], [dob], [UserId] FROM [Customers] WHERE ([UserId] = @UserId)"
DeleteCommand="DELETE FROM [Customers] WHERE [UserId] = @UserId"
InsertCommand="INSERT INTO [Customers] ([Bhousenum], [Bstreetname], [Bcity], [Bcounty], [Bcountry], [Dhousenum], [Dstreetname], [Dcity], [Dcounty], [Dcountry], [Dpostcode], [Bpostcode], [mobilenum], [credittype], [creditname], [creditnum], [securitycode], [creditexpiry], [dob], [UserId]) VALUES (@Bhousenum, @Bstreetname, @Bcity, @Bcounty, @Bcountry, @Dhousenum, @Dstreetname, @Dcity, @Dcounty, @Dcountry, @Dpostcode, @Bpostcode, @mobilenum, @credittype, @creditname, @creditnum, @securitycode, @creditexpiry, @dob, @UserId) WHERE [UserId] = @UserId"
UpdateCommand="UPDATE [Customers] SET [Bhousenum] = @Bhousenum, [Bstreetname] = @Bstreetname, [Bcity] = @Bcity, [Bcounty] = @Bcounty, [Bcountry] = @Bcountry, [Dhousenum] = @Dhousenum, [Dstreetname] = @Dstreetname, [Dcity] = @Dcity, [Dcounty] = @Dcounty, [Dcountry] = @Dcountry, [Dpostcode] = @Dpostcode, [Bpostcode] = @Bpostcode, [mobilenum] = @mobilenum, [credittype] = @credittype, [creditname] = @creditname, [creditnum] = @creditnum, [securitycode] = @securitycode, [creditexpiry] = @creditexpiry, [dob] = @dob WHERE [UserId] = @UserId">