| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6093 人关注过本帖
标题:关于列前缀与查询中所用的表名或别名不匹配的问题
取消只看楼主 加入收藏
fish16402
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-11-26
收藏
 问题点数:0 回复次数:3 
关于列前缀与查询中所用的表名或别名不匹配的问题
做了一个VB连接SQL2000的程序,并运行SQL语句创建几个表,但运行的时候出现如下错误:
[Microsoft][ODBC sql server driver][sql server]列前缀't_icitemcore'与查询中所用的表名或列名不匹配。
我如果在服务器的SQL2000查询分析器中直接运行下面包含的SQL语句是没问题的,放到VB代码中就出现这个错误,请高手看看到底是哪里错了,是不是写错了,在线等,万分感谢!!
Private Sub Command1_Click()
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
conn.C
conn.ConnectionTimeout = 30
conn.Open
rs.Open "select fitemid,fqty Into richard1 From iccustbomchild where finterid=(select finterid From icbom where fbomnumber='custbom000001')", conn, adOpenKeyset
rs.Open "select fnumber,fname,fmodel,fqty Into richard2 from t_ICItemCore innr join richard1 on t_ICItemCore.fitemid=richard1.fitemid", conn, adOpenKeyset
rs.Open "select finterid,fitemid,fqty Into richard3 From icbomchild where finterid in(select finterid From icbom where fitemid in(select fitemid From t_icitemcore where fnumber in(select fnumber From richard2 where fnumber like '2.%')))", conn, adOpenKeyset
rs.Open "select fnumber as 物料代码,fname as 物料名称,fmodel as 规格型号,fqty as 用量 Into richard4 from t_icitemcore inner join richard3 on t_icitemcore.fitemid=richard3.fitemid", conn, adOpenKeyset
rs.Open "select * from richard4"
Dim i As Long
Text1.Text = "物料编码" & "     -     " & "名称" & "     -     " & "规格型号" & "     -     " & vbCrLf
For i = 0 To rs.RecordCount - 1
    Text1.Text = Text1.Text & rs.Fields(0).Value & " - " & rs.Fields(1).Value & "      -      " & rs.Fields(2).Value & "      -      " & rs.Fields(3).Value & vbCrLf
    rs.MoveNext
Next
rs.Close
End Sub
搜索更多相关主题的帖子: 表名 前缀 别名 SQL 服务器 
2007-11-26 22:31
fish16402
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-11-26
收藏
得分:0 
顶一下,高手指点一下啊,我这是想把多条SQL语句在VB中执行,可能是语法错误,就是不知道错在哪里,在网上搜索也找不到相关的帖子!
2007-11-27 08:20
fish16402
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-11-26
收藏
得分:0 
说句实话,我现在还没理解conn.open和rs.open的意思,能不能解释下这两个命令后面都带什么啊,还有如果我要在VB里面运行多个SQL语句,我该怎么做,高手帮我改一下吧,昨天弄了一个晚上,我真是不知道怎么弄了!!
2007-11-27 08:36
fish16402
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-11-26
收藏
得分:0 
Private Sub Command1_Click()
Set conn = New ADODB.Connection
Set conn1 = New ADODB.Connection
Set conn2 = New ADODB.Connection
Set conn3 = New ADODB.Connection
Set rs = New ADODB.Recordset
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Set rs3 = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs1.CursorLocation = adUseClient
rs2.CursorLocation = adUseClient
rs3.CursorLocation = adUseClient
conn.ConnectionString = "driver={sql server};server=10.1.8.181;uid=sa;pwd=sa;database=ais20071122144144"
conn1.ConnectionString = "driver={sql server};server=10.1.8.181;uid=sa;pwd=sa;database=ais20071122144144"
conn2.ConnectionString = "driver={sql server};server=10.1.8.181;uid=sa;pwd=sa;database=ais20071122144144"
conn3.ConnectionString = "driver={sql server};server=10.1.8.181;uid=sa;pwd=sa;database=ais20071122144144"
conn.ConnectionTimeout = 30
conn1.ConnectionTimeout = 30
conn2.ConnectionTimeout = 30
conn3.ConnectionTimeout = 30
conn.Open
rs.Open "select fitemid,fqty Into richard1 From iccustbomchild where finterid=(select finterid From icbom where fbomnumber='custbom000001')", conn, adOpenKeyset
rs.Close
conn.Close
conn1.Open
rs1.Open "select fnumber,fname,fmodel,fqty Into richard2 from t_ICItemCore innr join richard1 on t_ICItemCore.fitemid=richard1.fitemid", conn, adOpenKeyset
End Sub
我改了一下,代码如上,但还是不行,我确实没理解这几段话的意思,能不能帮我看看是错在哪里,原理到底是什么,万分感谢!!
2007-11-27 09:43
快速回复:关于列前缀与查询中所用的表名或别名不匹配的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024103 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved