关于两个表取值的问题
我的两个表:information和category.两个表的全部字段如下,刚才没有写完:
information表中的字段:
cl_number(车辆序号),cph(车牌号),sj(车主手机号),cl_type_xh(车辆类别序号),in_time(入场时间),out_time(出场时间),flag(出场标志),in_yg_id(入场经办人),out_yg_id(出场经办人).
category表中的字段:
cl_type_xh(车辆类别序号),type_name(类型名称).
查到车辆类别序号.得到车牌号所对应的type_name(类型名称)
Dim rs_settlement As New ADODB.Recordset
Dim sql As String
Dim var As String
sql = "select cl_number,cph,sj,in_time,out_time,flag,in_yg_id,out_yg_id info.cl_type_xh,type_name from information as info,category as cate where info.cl_type_xh=cate.cl_type_xh and cph= ' "& Trim(txtcar.Text) & " ' And flag = 0 "
rs_settlement.Open sql, conn, adOpenKeyset, adLockPessimistic
var = rs_settlement.Filter(type_name)
执行后var = rs_settlement.Filter(type_name)提示type_name变量未定义,想把SQL查出来的type_name的值付给var,由于小弟不是很懂.请大侠帮忙解决一下,并请给我讲解.
[解决办法]
var = rs_settlement.Filter(type_name) 有问题
var 好像是关键字
type_name=rs_settlement.fields( "type_name ")
[解决办法]
var = rs_settlement!type_name