| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 461 人关注过本帖
标题:看看错在哪里?
只看楼主 加入收藏
shangji
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2007-7-1
收藏
 问题点数:0 回复次数:1 
看看错在哪里?

图片附件: 游客没有浏览图片的权限,请 登录注册

这是我截图 我是想在TEXT1和TEXT2中输入姓名和籍贯可以把数据库中详细准确记录输出来
我写的代码是:
Option Explicit
Private Sub Command1_Click()
Dim tidcard As String
Dim jiguan As String
Dim cnn As New ADODB.Connection
Dim ret As New ADODB.Recordset
Dim local_db As String
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path & "\data\db.mdb" + ";Persist Security Info=False;"
tidcard = Trim(Text1.Text)
jiguan = Trim(Text2.Text)
If Text1.Text = "" Then
MsgBox "请输入姓名", , "警告"
If Text2.Text = "" Then
MsgBox "请输入籍贯", "警告"
Text1.SetFocus
Text2.SetFocus
Else
Set ret = New ADODB.Recordset
local_db = "select * from 人口表" + _
" where 人口表.姓名=" + "'" + tidcard + "'"
ret.Open local_db, cnn
If ret.BOF And ret.EOF Then
MsgBox "无此姓名,请重新输入"
Text1.Text = ""
Text1.SetFocus
Else
Set ret = New ADODB.Recordset
local_db = "select * from 人口表" + _
" where 人口表.籍贯=" + "'" + jiguan + "'"
ret.Open local_db, cnn
If ret.BOF And ret.EOF Then
MsgBox "无此籍贯,请重新输入"
Text2.Text = ""
Text2.SetFocus

Else
Dim d1 As String
frmpren.Label2.Caption = ret("户号")
frmpren.Label38.Caption = ret("姓名")
frmpren.Label3.Caption = ret("与户主关系")
frmpren.Label39.Caption = ret("身份证号")
frmpren.Label4.Caption = ret("性别")
frmpren.Label8.Caption = ret("民族")
frmpren.Label29.Caption = ret("籍贯")
d1 = ret("出生日期")
frmpren.Label30.Caption = Mid(d1, 1, 4)
frmpren.Label31.Caption = Mid(d1, 5, 2)
frmpren.Label36.Caption = Mid(d1, 7, 2)
frmpren.Label34.Caption = ret("出生地")
frmpren.Label41.Caption = ret("文化程度")
frmpren.Label6.Caption = ret("婚姻状况")
frmpren.Label40.Caption = ret("职业")
frmpren.Label43.Caption = ret("工作单位")
frmpren.Label23.Caption = ret("迁入日期")
frmpren.Label28.Caption = ret("何地迁入")
ret.Close
Set ret = New ADODB.Recordset
local_db = "select * from 人迁出表" + _
" where 人迁出表.身份证号=" + "'" + tidcard + "'"
ret.Open local_db, cnn
If Not (ret.BOF And ret.EOF) Then
frmpren.Label26.Caption = ret("迁出日期")
frmpren.Label33.Caption = ret("迁往何地")
End If
Unload frmprint
frmpren.Show
frmpt2.Show
frmpren.Enabled = False
mainfrm.Enabled = False
mainfrm.Command5.Enabled = False
End If
End If
End If
End If

End Sub
但是不能正确运行 请帮帮忙 谢谢

搜索更多相关主题的帖子: 数据库 记录 False 
2007-07-04 12:00
酒肉弥勒佛
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:399
专家分:0
注 册:2006-6-6
收藏
得分:0 
哪句出错你也说出来啊, ret("迁出日期")??这个能用吗,我都是用ret.field(""),还真没有用过前者

编程是为了提高效率,好的程序是因为他的高效;在编程的道路上,永远追逐高效的算法
2007-07-04 19:56
快速回复:看看错在哪里?
数据加载中...
 
   



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

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