求高手指点
<P>这是我的一个读取sql里数据的vb,库里有很多条记录的,我怎么只能读出其中的第一条记录呀?高手们帮我看看吧!<BR>Private Sub hb_Click()<BR>Dim ysjlj As New ADODB.Connection<BR>Dim ygg01 As New ADODB.Recordset<BR>Dim xsjlj As New ADODB.Connection<BR>Dim xgg01 As New ADODB.Recordset<BR>Dim ygg1, xgg1 As String<BR>Dim yljzfc, xljzfc, ysj, xsj As String '源新数据库连接字符串</P><P>yljzfc = "provider=sqloledb.1;password=" & yyhmm.Text & ";persist security info=true;user id=" & yyhm.Text & ";initial catalog=" & ysjk.Text & " ;data source=" & yfwq.Text & ""<BR>ysjlj.Open yljzfc '连接源数据库</P>
<P>xljzfc = "provider=sqloledb.1;password=" & xyhmm.Text & ";persist security info=true;user id=" & xyhm.Text & ";initial catalog=" & xsjk.Text & " ;data source=" & xfwq.Text & ""<BR>xsjlj.Open xljzfc '连接源数据库<BR>'xsj = " select * into gg1 from gg01 where ga01='1'"<BR>'xgg01.Open xsj, xsjlj, adOpenKeyset, adLockPessimistic '在新数据库中新建gg1表<BR>'xgg01.Close<BR>'下面将源数据库中gg01表的内容导入到gg1表中。<BR>ysj = "select *from gg01 where ga033='114'"<BR>ygg01.Open ysj, ysjlj, adOpenKeyset, adLockPessimistic</P>
<P>xsj = "select * from gg1"<BR>xgg01.Open xsj, xsjlj, adOpenKeyset, adLockPessimistic<BR>i = 0<BR>If Not ygg01.EOF Then<BR>i = i + 1<BR> xgg01.AddNew<BR> xgg01.Fields("ga01") = ygg01.Fields("ga01")<BR> xgg01.Fields("ga18") = ygg01.Fields("ga18")<BR> xgg01.Fields("ga03") = ygg01.Fields("ga03")<BR> xgg01.Fields("ga04") = ygg01.Fields("ga04")<BR>'xgg01.Update<BR> 'Print ygg01.Fields("ga18")<BR> ygg01.MoveNext<BR> xgg01.MoveNext<BR> <BR>Else<BR> 'ygg01.Close<BR> 'xgg01.Close<BR> 'Exit Sub<BR>End If<BR> <BR> Print i</P>
<P>;我的i值怎么都是1,可是我的库里有很多行的.</P> <P>Do While Not ygg01.EOF </P>
<P>..........</P>
<P>Loop</P>
页:
[1]