<!-- 
蛙蛙请教:asp中Command的参数设置问题,请教一下.
为了方便大家了解问题真相,我把相关资料贴了一下,就是设置Command对象的CommandType的时候报错了,详细看我下面做的注释.
系统配置
:win2000sp4+update
IIS5.0
sqlserver2000+sql2ksp3+sql2kasp3
MDAC2.8
.NET FRAMEWORK 1.1
wawa_song表结构如下:
------------------------------------
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[wawa_song]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[wawa_song]
GOCREATE TABLE [dbo].[wawa_song] (
[song_id] [int] IDENTITY (1, 1) NOT NULL ,
[song_name] [char] (40) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[song_content] [varchar] (4000) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[song_author] [char] (20) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO
--------------------------------------
p_song存储过程的代码如下
--------------------------------------
CREATE PROCEDURE [p_song] AS
select * from wawa_song
GO
---------------------------------------
-->
<%
Dim conn,strconn
Set conn = Server.CreateObject("ADODB.Connection")
strconn="Driver={sql server};server=192.168.0.110;database=wawa;uid=sa;pwd=sa;"
conn.Open strconn
'***********************************************
'本来是想用下面的代码来着,可是老提示出错
'Dim cmdTest,rsTest
'Set cmdTest = Server.CreateObject("ADODB.Command")
'cmdTest.CommandText = "p_song"
'cmdTest.CommandType = adCmdStoredProc '这句提示出错:参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
'Set cmdTest.ActiveConnection = conn
'Set rsTest = cmdTest.Execute
'***********************************************
Dim rswawa
set rswawa=server.createobject("adodb.recordset")
rswawa.open "p_song",conn,1,1,4
dim page,mypagesize,totlepage
IF not IsNumeric(Request("page")) Or IsEmpty(Request("page")) Then
page=1
Else
Page=Int(Abs(Request("page")))
End if
rswawa.pagesize =4
totalpage=rswawa.pagecount
mypagesize=rswawa.pagesize
rswawa.absolutepage = page
While Not rswawa.EOF  and mypagesize>0
    Response.Write rswawa(1)  & "<br>"
    rswawa.MoveNext
mypagesize=mypagesize-1
Wend
conn.close
Set rswawa = Nothing
Set cmdwawa = Nothing: Set conn = Nothing
for i=1 to totalpage
response.write("<a href=t.asp?page="&i&">"&i&"</a>&nbsp;&nbsp;")
next
%>

解决方案 »

  1.   

    对应adovbs.inc文件把adCmdStoredProc改成数字值
      

  2.   

    再请教一个
    这是一个存储过程,我修改了别人一个
    CREATE        PROCEDURE                [DBO].[insert_SoftType]        
                     @SoftTypeName        char(20),
                     @out_err  int    output
    as
    Begin
                     declare        @exists        int
                     set    @exists=(select        count(*) from SoftType where SoftTypeName = @SoftTypeName)
                     if     @exists=0
                            insert into wawa_song(SoftTypeName)
                            values(@SoftTypeName)
     else
    set  @out_err=1                       
    end
    GO
    下面是我的使用,
    If Trim(Request.Form("submit"))<>"" Then
    SoftTypeName  =  request.Form("SoftTypeName")
    set  objcomm  =  server.CreateObject("adodb.command")
    with  objcomm
         .ActiveConnection=conn
         .CommandText="insert_SoftType"
         .CommandType=4
         set prmTest=.createparameter("out_err",adTinyInt,adParamOutput)' 为什么这句老出错呀,说"参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。 "
         .parameters.append prmTest
     set prmTest=.createparameter("@SoftTypeName",adchar,adparaminput,20,SoftTypeName)
         .Parameters.append prmTest
     .Execute  lng,,adexecutenorecords
    end  with
    dim out_err
    out_err=cint(objcomm.Parameters("out_err").Value)
    if out_err=1 then
    resposne.write("已经有了这个类别了")
    else
    response.write("添加成功")
    end if
    response.Write  "有"&lng&"条记录受到影响!"
    set  objcomm  =  nothing
    End If
      

  3.   

    按照我说的修改能成功吗?
    如果成功的话,也是同样的问题了查找adovbs.inc改成数字值
      

  4.   

    adCmdStoredProc = &H0004adTinyInt = 16
    adParamOutput = &H0002
      

  5.   

    Function FieldType(intType)
       Select Case intType
          Case 20
             FieldType = "int"
          Case 128
             FieldType = "binary"
          Case 11
             FieldType = "bit"
          Case 129
             FieldType = "char"
          Case 135
             FieldType = "datetime"
          Case 131
             FieldType = "varchar"
          Case 5
             FieldType = "float"
          Case 205
             FieldType = "image"
          Case 3
             FieldType = "int"
          Case 6
             FieldType = "money"
          Case 130
             FieldType = "char"
          Case 203
             FieldType = "text"
          Case 131
             FieldType = "numeric"
          Case 202
             FieldType = "varchar"
          Case 4
             FieldType = "real"
          Case 135
             FieldType = "datetime"
          Case 2
             FieldType = "int"
          Case 6
             FieldType = "money"
          Case 204
             FieldType = "varchar"
          Case 201
             FieldType = "text"
          Case 128
             FieldType = "timestamp"
          Case 17
             FieldType = "varchar"
          Case 72
             FieldType = "varchar"
          Case 204
             FieldType = "varbinary"
          Case 200
             FieldType = "varchar"
        End Select
    End Function