I am trying to build a master-detail setup for conference registration.
Page1 is the company information
Page2 is the participant information.
One company can have many participants being registered. The tables are tied together with RegID - the primary key identity value in the master table and the foreign key in the detail table.
The stored procedure itself seems to work OK - the data input into the form on Page1 DOES get inserted into the master table.
However, it won't redirect to Page2. After the form on Page1 is submitted, it stays on that form with an error message that says "
Error converting data type int to nvarchar"
I have spent hours trying to fix this to no avail. Please help.
SP:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--
CREATE PROCEDURE [dbo].[ssInsertCompany2]
@CompanyName varchar(100),
@Address varchar(50),
@City varchar(50),
@State varchar(50),
@Zip varchar(50),
@Website varchar(50),
@NewRegID int OUTPUT
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO [tblRegistration2] ([CompanyName], [Address], [City], [State], [Zip], [Website]) VALUES(@CompanyName, @Address, @City, @State, @Zip, @Website);
set @NewRegID=SCOPE_IDENTITY();
END
NOTE: I also tried SELECT instead of SET on the SCOPE IDENTITY LINE
Form Code:
<SubmitCommand CommandText="dbo.ssInsertCompany2" CommandType="StoredProcedure" ConnectionString="Data Source=U15343166;Initial Catalog=Registrations;User ID=ConfReg;Password=RegConf1700"> <Parameter Name="CompanyName" DataType="string"/><Parameter Name="Address" DataType="string"/><Parameter Name="City" DataType="string"/><Parameter Name="State" DataType="string"/><Parameter Name="Zip" DataType="string"/><Parameter Name="Website" DataType="string"/><Parameter Name="NewRegID" Direction="Output" DataType="Int64"/>
</SubmitCommand>
<div>
<div><Label CssClass="xmp-form-label NormalBold" For="CompanyName">Company Name</Label><TextBox Id="CompanyName" Width="300" Nullable="true" MaxLength="100" DataField="CompanyName" DataType="string"></TextBox></div>
<div><Label CssClass="xmp-form-label NormalBold" For="Address">Address</Label><TextBox Id="Address" Width="250" Nullable="true" MaxLength="50" DataField="Address" DataType="string"></TextBox></div>
<div><Label CssClass="xmp-form-label NormalBold" For="City">City</Label><TextBox Id="City" Width="200" Nullable="True" MaxLength="50" DataField="City" DataType="string"></TextBox></div>
<div><Label CssClass="xmp-form-label NormalBold" For="State">State</Label><TextBox Id="State" Width="75" Nullable="true" MaxLength="50" DataField="State" DataType="string"></TextBox></div>
<div><Label CssClass="xmp-form-label NormalBold" For="Zip">Zip</Label><TextBox Id="Zip" Width="100" Nullable="true" MaxLength="50" DataField="Zip" DataType="string"></TextBox></div>
<div><Label CssClass="xmp-form-label NormalBold" For="Website">Website</Label><TextBox Id="Website" Width="225" Nullable="true" MaxLength="50" DataField="Website" DataType="string"></TextBox></div>
<div><Label> </Label>
<p> </p>
<CancelButton Text="Cancel" Visible="true"></CancelButton><AddButton Text="Add Participants" style="margin-left: 12px;" Redirect="/Maintenance/Comps2EE.aspx
?NewRegID=[[NewRegID]]"
RedirectMethod="Get"></AddButton></div>
</div>
</AddForm>
NOTE: I used int32 for a while...thought I would try the 64. Doesn't matter...same error message
Thank you