Forums
This topic is locked
updating multiple tables with a single form
17 Nov 2007 18:36:26 mike west posted:
Hi all. I'm about at my wits end with this. I need to update 2 tables with one form. I've looked all over for how to do this and i keep hearing that i need to do two inserts on one form to get this to happen. The problem when I do this is that one table gets the record and the 2nd table gets nothing. I'm including my code here in hopes that someone can tell me what I am missing.<MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert
runat="server"
CommandText='<%# "INSERT INTO dbo.PendingCore (School, ID, LastName, FirstName, GradeLevel, Gender, Ethnicity, Birthdate, StNum, StName, POBox, City, Zip, Phone) VALUES (@School, @ID, @LastName, @FirstName, @GradeLevel, @Gender, @Ethnicity, @Birthdate, @StNum, @StName, @POBox, @City, @Zip, @Phone)" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_test" %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_test" %>'
Expression='<%# Request.Form("MM_insert" = "form1" %>'
CreateDataSet="false"
SuccessURL='<%# "addstudent.aspx" %>'
Debug="true"
><Parameters>
<Parameter Name="@School" Value='<%# IIf((Request.Form("schoolattending" <> Nothing), Request.Form("schoolattending", "" %>' Type="NChar" />
<Parameter Name="@ID" Value='<%# IIf((Request.Form("StudentID" <> Nothing), Request.Form("StudentID", "" %>' Type="NChar" />
<Parameter Name="@LastName" Value='<%# IIf((Request.Form("LastName" <> Nothing), Request.Form("LastName", "" %>' Type="NChar" />
<Parameter Name="@FirstName" Value='<%# IIf((Request.Form("FirstName" <> Nothing), Request.Form("FirstName", "" %>' Type="NChar" />
<Parameter Name="@GradeLevel" Value='<%# IIf((Request.Form("Grade" <> Nothing), Request.Form("Grade", "" %>' Type="NChar" />
<Parameter Name="@Gender" Value='<%# IIf((Request.Form("Gender" <> Nothing), Request.Form("Gender", "" %>' Type="NChar" />
<Parameter Name="@Ethnicity" Value='<%# IIf((Request.Form("Ethnicity" <> Nothing), Request.Form("Ethnicity", "" %>' Type="NChar" />
<Parameter Name="@Birthdate" Value='<%# IIf((Request.Form("DateOfBirth" <> Nothing), Request.Form("DateOfBirth", "" %>' Type="NChar" />
<Parameter Name="@StNum" Value='<%# IIf((Request.Form("StNum" <> Nothing), Request.Form("StNum", "" %>' Type="NChar" />
<Parameter Name="@StName" Value='<%# IIf((Request.Form("StName" <> Nothing), Request.Form("StName", "" %>' Type="NChar" />
<Parameter Name="@POBox" Value='<%# IIf((Request.Form("POBox" <> Nothing), Request.Form("POBox", "" %>' Type="NChar" />
<Parameter Name="@City" Value='<%# IIf((Request.Form("City" <> Nothing), Request.Form("City", "" %>' Type="NChar" />
<Parameter Name="@Zip" Value='<%# IIf((Request.Form("Zip" <> Nothing), Request.Form("Zip", "" %>' Type="NChar" />
<Parameter Name="@Phone" Value='<%# IIf((Request.Form("phone" <> Nothing), Request.Form("phone", "" %>' Type="NChar" />
</Parameters>
</MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert>
<MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert
runat="server"
CommandText='<%# "INSERT INTO dbo.PendingDemo2 (School, ID, ParentName, BusinessPhone) VALUES (@School, @ID, @ParentName, @BusinessPhone)" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_test" %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_test" %>'
Expression='<%# Request.Form("MM_insert" = "form1" %>'
CreateDataSet="false"
Debug="true"
><Parameters>
<Parameter Name="@School" Value='<%# IIf((Request.Form("schoolattending" <> Nothing), Request.Form("schoolattending", "" %>' Type="NChar" />
<Parameter Name="@ID" Value='<%# IIf((Request.Form("StudentID" <> Nothing), Request.Form("StudentID", "" %>' Type="NChar" />
<Parameter Name="@ParentName" Value='<%# IIf((Request.Form("ParentName" <> Nothing), Request.Form("ParentName", "" %>' Type="NChar" />
<Parameter Name="@BusinessPhone" Value='<%# IIf((Request.Form("BusinessPhone" <> Nothing), Request.Form("BusinessPhone", "" %>' Type="NChar" />
</Parameters>
</MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert>