- UID
- 343088
- 积分
- 237
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-10-28
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
这是我的一个读取sql里数据的vb,库里有很多条记录的,我怎么只能读出其中的第一条记录呀?高手们帮我看看吧!
Private Sub hb_Click()
Dim ysjlj As New ADODB.Connection
Dim ygg01 As New ADODB.Recordset
Dim xsjlj As New ADODB.Connection
Dim xgg01 As New ADODB.Recordset
Dim ygg1, xgg1 As String
Dim yljzfc, xljzfc, ysj, xsj As String '源新数据库连接字符串
yljzfc = "provider=sqloledb.1;password=" & yyhmm.Text & ";persist security info=true;user id=" & yyhm.Text & ";initial catalog=" & ysjk.Text & " ;data source=" & yfwq.Text & ""
ysjlj.Open yljzfc '连接源数据库
xljzfc = "provider=sqloledb.1;password=" & xyhmm.Text & ";persist security info=true;user id=" & xyhm.Text & ";initial catalog=" & xsjk.Text & " ;data source=" & xfwq.Text & ""
xsjlj.Open xljzfc '连接源数据库
'xsj = " select * into gg1 from gg01 where ga01='1'"
'xgg01.Open xsj, xsjlj, adOpenKeyset, adLockPessimistic '在新数据库中新建gg1表
'xgg01.Close
'下面将源数据库中gg01表的内容导入到gg1表中。
ysj = "select *from gg01 where ga033='114'"
ygg01.Open ysj, ysjlj, adOpenKeyset, adLockPessimistic
xsj = "select * from gg1"
xgg01.Open xsj, xsjlj, adOpenKeyset, adLockPessimistic
i = 0
If Not ygg01.EOF Then
i = i + 1
xgg01.AddNew
xgg01.Fields("ga01") = ygg01.Fields("ga01")
xgg01.Fields("ga18") = ygg01.Fields("ga18")
xgg01.Fields("ga03") = ygg01.Fields("ga03")
xgg01.Fields("ga04") = ygg01.Fields("ga04")
'xgg01.Update
'Print ygg01.Fields("ga18")
ygg01.MoveNext
xgg01.MoveNext
Else
'ygg01.Close
'xgg01.Close
'Exit Sub
End If
Print i
;我的i值怎么都是1,可是我的库里有很多行的. |
|