我把7.0用access数据库改为用sql2000数据库后。添加自定义表单时提示此环境中不允许操作。
以下是添加自定义表单的代码:
-
Sub FormSave()
- Dim ExpiredDate,StartDate,I,OpName,ID:ID=KS.ChkClng(KS.G("ID"))
- StartDate=KS.G("StartDate")
- ExpiredDate=KS.G("ExpiredDate")
- If Not IsDate(StartDate) Then Call KS.AlertHistory("生效日期格式不正确",-1):response.end
- If Not IsDate(ExpiredDate) Then Call KS.AlertHistory("失效日期格式不正确",-1):response.end
- If ID=0 and Not Conn.Execute("select top 1 id from ks_form where tablename='KS_Form_" & KS.G("TableName") &"'").eof then Call KS.AlertHistory("数据表已存在!",-1):response.end
- on error resume next
- Conn.BeginTrans
- Dim RS:Set RS=Server.CreateObject("ADODB.RECORDSET")
- RS.Open "Select * From KS_Form Where ID=" & ID,Conn,1,3
- If RS.Eof And RS.Bof Then
- RS.AddNew
- RS("TableName")= "KS_Form_" & KS.G("TableName")
- OpName = "添加"
- Else
- OpName="修改"
- End If
- RS("FormName")= KS.G("FormName")
- RS("UploadDir")= KS.G("UpLoadDir")
- RS("Status") = KS.G("Status")
- RS("TimeLimit") = KS.ChkClng(KS.G("TimeLimit"))
- RS("StartDate") = startdate
- RS("ExpiredDate") = ExpiredDate
- RS("useronce") =KS.ChkClng(KS.G("useronce"))
- rs("onlyuser")=KS.ChkClng(KS.G("onlyuser"))
- rs("shownum")=ks.chkclng(ks.g("shownum"))
- RS("AllowGroupID") = KS.G("AllowGroupID")
- RS("Descript") = KS.G("Descript")
- RS("PostByStep") = KS.ChkClng(KS.G("PostByStep"))
- RS("StepNum") = KS.ChkClng(KS.G("StepNum"))
- RS("ToUserEmail") = KS.ChkClng(KS.G("ToUserEmail"))
- RS.Update
- RS.Close
- Set RS=Nothing
-
- If OpName="添加" Then
- Dim sql:sql="CREATE TABLE [KS_Form_" & KS.G("TableName") & "] ([ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_KS_Form_" & KS.G("TableName") & " PRIMARY KEY,"&_
- "UserName nvarchar(100),"&_
- "UserIP nvarchar(100),"&_
- "AddDate datetime,"&_
- "[Note] text,"&_
- "Status tinyint default 0)"
- Conn.Execute(sql)
- End If
- if err<>0 then
- Conn.RollBackTrans
- Call KS.AlertHistory("出错!出错描述:" & replace(err.description,"'","\'"),-1):response.end
- else
- Conn.CommitTrans
- Response.Write ("<script>alert('" & OpName & "自定义表成功!');location.href='KS.Form.asp';</script>")
- end if
- End Sub
不知道问题出在哪里。生成的sql语句我在sql2000的查询分析器里也执行过。没有错误。