sql语句移到VB.NET中出现问题,谁能解决?
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[outprint]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[outprint]
为什么上述语名移到VB.NET中老是出现下面错误:
“未处理的"System.runtime.interopservices.COMException"类型的异常出现在××.EXE中。
其他信息:对象关闭时,不允许操作,”
整个语句环境如下:
MyCnn = New ADODB.Connection
Dim strCn As String
strCn = "DSN=jxc;UID=summer;PWD=dong"
MyCnn.Open(strCn)
MyRS = New ADODB.Recordset
strsql = "if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[outprint]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) "
strsql += "drop table [dbo].[outprint] "
strsql += "select * into outprint from intz "
strsql += "delete outprint where len(str(code))>0 "
strsql += "select * from outprint"
MyRS.Open(strsql, MyCnn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
MyRS.AddNew()
With MyRS
.Fields(0).Value = Trim(TextBox9.Text)
.Fields(1).Value = Trim(TextBox2.Text)
.Fields(2).Value = Trim(TextBox3.Text)
End With
MyRS.Update()
MyRS.Close()
[此贴子已经被作者于2006-11-29 20:32:06编辑过]