我有一个允许用户报告事情的表格。我正在尝试使用 asp 和 SQL 存储过程来运行它,但我无法让它工作!
非常感谢任何帮助!
这是asp/vb:
Dim insertVictim__firstName
insertVictim__firstName = null
if(Request.form("firstName") <> "") then insertVictim__firstName = Request.form("firstName")
Dim insertVictim__surName
insertVictim__surName = null
if(Request.form("surName") <> "") then insertVictim__surName = Request.form("surName")
Dim insertVictim__Gender
insertVictim__Gender = null
if(Request.form("Gender") <> "") then insertVictim__Gender = Request.form("Gender")
Dim insertVictim__DOB
insertVictim__DOB = null
if(Request.form("DOB") <> "") then insertVictim__DOB = Request.form("DOB")
set insertVictim = Server.CreateObject("ADODB.Command")
insertVictim.ActiveConnection = MM_SecurityReporting_STRING
insertVictim.CommandText = "dbo.sp_insertIntoVictim"
insertVictim.Parameters.Append insertVictim.CreateParameter("@firstName", 200, 1,20,insertIncident__firstName)
insertVictim.Parameters.Append insertVictim.CreateParameter("@surName", 200, 1,20,insertIncident__surName)
insertVictim.Parameters.Append insertVictim.CreateParameter("@Gender", 200, 1,20,insertIncident__Gender)
insertVictim.Parameters.Append insertVictim.CreateParameter("@DOB", 200, 1,20,insertIncident__DOB)
insertVictim.CommandType = 4
insertVictim.CommandTimeout = 0
insertVictim.Prepared = true
insertVictim.Execute()
这是 SQL 存储过程:
USE [SecurityReporting]
GO
/****** Object: StoredProcedure [dbo].[sp_insertIntoVictim] Script Date: 07/08/2013 16:59:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[sp_insertIntoVictim]
-- Add the parameters for the stored procedure here
@firstName varchar(20),
@surName varchar(20),
@Gender varchar(20),
@DOB varchar(20)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
insert into tbl_victim (firstName, surName, Gender, DOB)
values (@firstName, @surName, @Gender, @DOB)
END