在VBScript(ASP环境)中,是否可以将一个空值传递给存储过程?
解决方法
使用命令对象将null传递给存储过程.
Set cn = CreateObject("ADODB.Connection") Set cmd = CreateObject("ADODB.Command") cn.Open "Provider=sqlOLEDB.1;Integrated Security=SSPI;Data Source=.\Test" Set cmd.ActiveConnection = cn cmd.CommandText = "TestTable.sp_ModifyData" cmd.CommandType = 4 cmd.NamedParameters = True set cnParam = cmd.CreateParameter("@RowID",3,-1) cmd.Parameters.Append cnParam set cnParam = cmd.CreateParameter("@AddRemoveModify",1,0) cmd.Parameters.Append cnParam set cnParam = cmd.CreateParameter("@Value1",0) cmd.Parameters.Append cnParam set cnParam = cmd.CreateParameter("@Value2",8,-1,"Test") cmd.Parameters.Append cnParam set cnParam = cmd.CreateParameter("@value3",5,null) cmd.Parameters.Append cnParam set cnParam = cmd.CreateParameter("@value4",0) cmd.Parameters.Append cnParam set cnParam = cmd.CreateParameter("@value5","") cmd.Parameters.Append cnParam cmd.Execute cn.Close Set cmd = Nothing Set cn = Nothing
对不起,我没有太多思考命名我的数据库中的字段.