我有以下储存程序:
ALTER PROCEDURE Pro_members_Insert
@id int outPut,
@LoginName nvarchar(50),
@Password nvarchar(15),
@FirstName nvarchar(100),
@LastName nvarchar(100),
@signupDate smalldatetime,
@Company nvarchar(100),
@Phone nvarchar(50),
@Email nvarchar(150),
@Address nvarchar(255),
@PostalCode nvarchar(10),
@State_Province nvarchar(100),
@City nvarchar(50),
@countryCode nvarchar(4),
@active bit,
@activationCode nvarchar(50)
AS
declare @usName as varchar(50)
set @usName=
select @usName=isnull(LoginName, ) from members where LoginName=@LoginName
if @usName <>
begin
set @ID=-3
RAISERROR( User Already exist. , 16, 1)
return
end
set @usName=
select @usName=isnull(email, ) from members where Email=@Email
if @usName <>
begin
set @ID=-4
RAISERROR( Email Already exist. , 16, 1)
return
end
declare @MemID as int
select @memID=isnull(max(ID),0)+1 from members
INSERT INTO members (
id,
LoginName,
Password,
FirstName,
LastName,
signupDate,
Company,
Phone,
Email,
Address,
PostalCode,
State_Province,
City,
countryCode,
active,activationCode)
VALUES (
@Memid,
@LoginName,
@Password,
@FirstName,
@LastName,
@signupDate,
@Company,
@Phone,
@Email,
@Address,
@PostalCode,
@State_Province,
@City,
@countryCode,
@active,@activationCode)
if @@error <> 0
set @ID=-1
else
set @id=@memID
请注意,我已“继承”这一提纲和数据库。
我正试图在我签字时插入一个新的记录。 MyDataSource如下:
<asp:SqlDataSource runat="server" ID="dsAddMember"
ConnectionString="rmsdbuser"
InsertCommandType="StoredProcedure" InsertCommand="Pro_members_Insert"
ProviderName="System.Data.SqlClient">
<InsertParameters>
<asp:ControlParameter ControlID="txtLoginName" Type="String" />
<asp:ControlParameter ControlID="txtPassword" Type="String" />
<asp:ControlParameter ControlID="txtEmail" Type="String" />
<asp:ControlParameter ControlID="txtCompany" Type="String" />
<asp:ControlParameter ControlID="txtFirstName" Type="String" />
<asp:ControlParameter ControlID="txtLastName" Type="String" />
<asp:ControlParameter ControlID="txtAddress" Type="String" />
<asp:ControlParameter ControlID="txtCity" Type="String" />
<asp:ControlParameter ControlID="ddlState" type="String" />
<asp:ControlParameter ControlID="ddlcountryCode" Type="String" />
<asp:ControlParameter ControlID="txtPostalCode" Type="String" />
<asp:ControlParameter ControlID="txtPhoneNumber" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
点击手套 除此以外:
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
Try
dsAddMember.DataBind()
Catch ex As Exception
End Try
End Sub
当我管理这一页时,标注.aspx提供所需领域和点击提交,该页只是重载,数据库表没有反映新列入的记录。
问题:
- How do I catch the error messages that might be returned from the sproc?
- Please advise how to change signup.aspx so that the insert occurs.
Thanks, Sid