我有一個允許用戶報告事物的表單。我試圖使用asp和一個SQL存儲過程來運行它,但我無法讓它工作!使用存儲過程不工作的INSERT查詢
任何幫助非常感謝!
這是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
「*我無法讓它工作*」對我們沒有多大幫助。怎麼了?有錯誤嗎? –
與您的問題沒有關係,但將出生日期存儲爲varchar而非日期是個不錯的主意。 –
感謝您的意見,沒有錯誤或任何東西!只是沒有插入表中的值:( – neeko