搞定了了。谢谢大家。以下是代码,拿出来共享了。要使用先引用控件 Sub Macro1()
Dim CNN As New ADODB.Connection, RST As New ADODB.Recordset
Dim CNN1 As New ADODB.Connection, RST1 As New ADODB.Recordset Dim DsPath As String, dspath1 As String, strSQL As String, strSQL1 As String, strPro As String, mingjia As String, mingjianame As String, mybiaoti As String, mytoubaoren As String, myyinyan As String
Dim myjieshu As String, mytese As String, mydate As String, myheji As Integer, myheji1, myheji2
Dim mybaoxian1 As String, mybaoxian2 As String, mybaoxian3 As String, mybaoxian4 As String, mybaoxian5 As String, mybaoxian6 As String, mybaoxian7 As String, mybaoxian8 As String, mybaoxian9 As String, mybaoxian0 As String
Dim myjiaofei1 As String, myjiaofei2 As String, myjiaofei3 As String, myjiaofei4 As String, myjiaofei5 As String, myjiaofei6 As String, myjiaofei7 As String, myjiaofei8 As String, myjiaofei9 As String, myjiaofei10 As String
Dim myqijian1 As String, myqijian2 As String, myqijian3 As String, myqijian4 As String, myqijian5 As String, myqijian6 As String, myqijian7 As String, myqijian8 As String, myqijian9 As String, myqijian10 As String
Dim mybaoe1 As String, mybaoe2 As String, mybaoe3 As String, mybaoe4 As String, mybaoe5 As String, mybaoe6 As String, mybaoe7 As String, mybaoe8 As String, mybaoe9 As String, mybaoe10 As String
Dim mybaofei1 As String, mybaofei2 As String, mybaofei3 As String, mybaofei4 As String, mybaofei5 As String, mybaofei6 As String, mybaofei7 As String, mybaofei8 As String, mybaofei9 As String, mybaofei10 As String
DsPath = "e:\编程序相关\Data.mdb"
dspath1 = "e:\编程序相关\chinesejoy.mdb"
strPro = "Microsoft.Jet.OLEDB.4.0"
'打开数据源的连接
CNN.Open "Provider=" & strPro & ";Data Source=" & DsPath
CNN1.Open "Provider=" & strPro & ";Data Source=" & dspath1
'SQL查询语句,从名为VariantType的表中读取ID列为值为5的Name列数据
strSQL = "SELECT * FROM temp where id = 'now'"
strSQL1 = "SELECT * FROM 个人信息 where id = 'now'"
'打开该表
RST.Open strSQL, CNN, adOpenKeyset, adLockOptimistic, adCmdText
RST1.Open strSQL1, CNN1, adOpenKeyset, adLockOptimistic, adCmdText mingjia = RST.Fields("名家明言")
mingjianame = RST.Fields("名家名字")
mybiaoti = RST.Fields("计划书标题")
mytoubaoren = RST.Fields("投保人姓名")
mytphone = RST1.Fields("电话")
myname = RST1.Fields("姓名")
myadd = RST1.Fields("公司地址")
myinfo = RST.Fields("险种名称")
myyinyan = RST.Fields("引言内容")
mytese = RST.Fields("保单特色内容")
myjieshu = RST.Fields("结束语内容")
mybaoxian1 = RST.Fields("险种名称")
myqijian1 = RST.Fields("保险期间")
myjiaofei1 = RST.Fields("缴费方式")
mybaofei1 = RST.Fields("保费")
mybaoe1 = RST.Fields("保额")
myheji = RST.Fields("合计")
mydate = Date
RST.Close '关闭数据表
Set RST = Nothing '释放对象
Set CNN = Nothing '翻译对象
RST1.Close '关闭数据表
Set RST1 = Nothing '释放对象
Set CNN1 = Nothing '翻译对象 |