读取数据库记录求助
代码如下:Public Function Query_Data(Order)
Dim Conn,sqlStr,Res,sql,str
Set Conn = CreateObject("ADODB.Connection")
sqlStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Mercury Interactive\QuickTest
Professional\samples\flight\app\flight32.mdb"
Conn.open sqlStr
sql = "SELECT dbo.Orders.Customer_Name, dbo.Orders.Order_Number, dbo.Flights.Airlines, dbo.Flights.Flight_Number,
dbo.Orders.Tickets_Ordered, dbo.Orders.Class, dbo.Flights.Ticket_Price, dbo.Orders.Departure_Date,
dbo.Flights.Day_Of_Week,dbo.Flights.Departure_Initials, dbo.Flights.Departure, dbo.Flights.Departure_Time,
dbo.Flights.Arrival_Initials, dbo.Flights.Arrival, dbo.Flights.Arrival_Time
FROM dbo.Flights inner join dbo.Orders on dbo.Flights.Flight_Number = dbo.Orders.Flight_Number
where Orders.Order_Number = '"& Order &"' "
Set Res = CreateObject("ADODB.Recordset")
Res.open sql,conn,1,3,1(运行到这一步,提示"Join 错误",估计是SQL语句的问题,但我在数据库中是可以正常运行的,不知道是不是不能进
行多表联合查询)
再下一步,我想把读出的记录集的第一行记录的每个字段的值连接起来组成一个字符串,并把它存入变量"str"
End Function
请各位朋友帮我修改并补充代码。
谢谢! join应该没有问题的,是不是搜索结果有问题。
你可以先根据join命令建立一个view(视图)试试,看看语句有没有问题。
页:
[1]