日期:2014-05-17  浏览次数:21104 次

请教asp中.execute执行sql语句时的问题
mystr= "insert   into   aaa   select   *   from   bbb   where   name= 'tom ' "
myconn.execute(mystr)
或者
myconn.execute( "insert   into   aaa   select   *   from   bbb   where   name= 'tom ' ")
都可以顺利执行
但是
xm= "tom "
mystr= "insert   into   aaa   select   *   from   aaa   where   name= ' "&xm& " ' "
myconn.execute(mystr)
或者
myconn.execute( "insert   into   aaa   select   *   from   bbb   where   name= ' "&xm& " ' ")
却不能向bbb表中加入任何记录
请教问题出在哪里?
因为实际需要,必须动态获得name的值
有什么解决的办法?
非常感谢

------解决方案--------------------
看不出有什么错,你看看是不是在别处搞错了
又或者你把aaa ,bbb表的字段有那些说一下,他们的顺序类型要对应的哦
------解决方案--------------------
xm= "tom "
mystr= "insert into aaa select * from bbb where name= ' "&xm& " ' "
↑这里有没有写错
myconn.execute(mystr)
------解决方案--------------------
在myconn.execute(mystr)前一句
加上:response.write(mystr)看看打印出来是什么代码
------解决方案--------------------
也许是你选择的语言不对吧,这个是在vbscript环境下,你是不是搞在其它环境下去了?
------解决方案--------------------
xm= "tom "
mystr= "insert into aaa select * from aaa where name= ' "&xm& " ' "
myconn.execute(mystr)

这个写错了,第二个aaa应该是bbb吧

-------------------------------
本人目前辞职,有需要兼职的网络编程工作请联系我