VBA 问题 哪错了???ODBC, ADODB.Command

chenxianping1979 2006-09-25 12:00:42
Dim CnStr As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim comd As ADODB.Command
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set comd = CreateObject("adodb.command")

'cn.Open "Driver={Microsoft ODBC for Oracle};Server=V11L30.PRONES;", "SIX", "SIX", -1
' cn.Open "Provider=MSDAORA.1;Password=SIX;User ID=SIX;Data Source=V11L30;Persist Security Info=True"
cn.Open "Driver={Microsoft ODBC for Oracle};Server=V11L30;Uid=SIX;Pwd=SIX;"
comd.ActiveConnection = cn
comd.CommandText = "Inert into TempleTable (ABC) values('abcde')"
comd.CommandType = adCmdText
comd.Execute
Set comd = Nothing
cn.Close
哪错了? 为什么一执行 comd.Execute就出错??
...全文
121 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
gudyn 2006-09-25
  • 打赏
  • 举报
回复
我在Excel中测试过!
gudyn 2006-09-25
  • 打赏
  • 举报
回复
不知道你的为什么错,但是如果你的SQL语句没写错像下面这样是可以的:
Dim CnStr As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim comd As ADODB.Command
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set comd = CreateObject("adodb.command")

cn.Open "Provider=MSDAORA;Data Source=V11L30;User ID=SIX;Password=SIX"
comd.ActiveConnection = cn
comd.CommandText = "Inert into TempleTable (ABC) values('abcde')"
comd.CommandType = adCmdText
comd.Execute
Set comd = Nothing
cn.Close

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧