Forums

This topic is locked

updating multiple tables with a single form

Posted 17 Nov 2007 18:36:26
1
has voted
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.

&lt;MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert
runat="server"
CommandText='&lt;%# "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)" %&gt;'
ConnectionString='&lt;%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_test" %&gt;'
DatabaseType='&lt;%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_test" %&gt;'
Expression='&lt;%# Request.Form("MM_insert" = "form1" %&gt;'
CreateDataSet="false"
SuccessURL='&lt;%# "addstudent.aspx" %&gt;'
Debug="true"
&gt;&lt;Parameters&gt;
&lt;Parameter Name="@School" Value='&lt;%# IIf((Request.Form("schoolattending" &lt;&gt; Nothing), Request.Form("schoolattending", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@ID" Value='&lt;%# IIf((Request.Form("StudentID" &lt;&gt; Nothing), Request.Form("StudentID", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@LastName" Value='&lt;%# IIf((Request.Form("LastName" &lt;&gt; Nothing), Request.Form("LastName", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@FirstName" Value='&lt;%# IIf((Request.Form("FirstName" &lt;&gt; Nothing), Request.Form("FirstName", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@GradeLevel" Value='&lt;%# IIf((Request.Form("Grade" &lt;&gt; Nothing), Request.Form("Grade", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@Gender" Value='&lt;%# IIf((Request.Form("Gender" &lt;&gt; Nothing), Request.Form("Gender", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@Ethnicity" Value='&lt;%# IIf((Request.Form("Ethnicity" &lt;&gt; Nothing), Request.Form("Ethnicity", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@Birthdate" Value='&lt;%# IIf((Request.Form("DateOfBirth" &lt;&gt; Nothing), Request.Form("DateOfBirth", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@StNum" Value='&lt;%# IIf((Request.Form("StNum" &lt;&gt; Nothing), Request.Form("StNum", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@StName" Value='&lt;%# IIf((Request.Form("StName" &lt;&gt; Nothing), Request.Form("StName", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@POBox" Value='&lt;%# IIf((Request.Form("POBox" &lt;&gt; Nothing), Request.Form("POBox", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@City" Value='&lt;%# IIf((Request.Form("City" &lt;&gt; Nothing), Request.Form("City", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@Zip" Value='&lt;%# IIf((Request.Form("Zip" &lt;&gt; Nothing), Request.Form("Zip", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@Phone" Value='&lt;%# IIf((Request.Form("phone" &lt;&gt; Nothing), Request.Form("phone", "" %&gt;' Type="NChar" /&gt;
&lt;/Parameters&gt;
&lt;/MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert&gt;
&lt;MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert
runat="server"
CommandText='&lt;%# "INSERT INTO dbo.PendingDemo2 (School, ID, ParentName, BusinessPhone) VALUES (@School, @ID, @ParentName, @BusinessPhone)" %&gt;'
ConnectionString='&lt;%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_test" %&gt;'
DatabaseType='&lt;%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_test" %&gt;'
Expression='&lt;%# Request.Form("MM_insert" = "form1" %&gt;'
CreateDataSet="false"
Debug="true"
&gt;&lt;Parameters&gt;
&lt;Parameter Name="@School" Value='&lt;%# IIf((Request.Form("schoolattending" &lt;&gt; Nothing), Request.Form("schoolattending", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@ID" Value='&lt;%# IIf((Request.Form("StudentID" &lt;&gt; Nothing), Request.Form("StudentID", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@ParentName" Value='&lt;%# IIf((Request.Form("ParentName" &lt;&gt; Nothing), Request.Form("ParentName", "" %&gt;' Type="NChar" /&gt;
&lt;Parameter Name="@BusinessPhone" Value='&lt;%# IIf((Request.Form("BusinessPhone" &lt;&gt; Nothing), Request.Form("BusinessPhone", "" %&gt;' Type="NChar" /&gt;
&lt;/Parameters&gt;
&lt;/MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert&gt;

Reply to this topic