Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having a problem with moving through recordset

Status
Not open for further replies.

DeeRuff1

Programmer
May 17, 2005
17
US
Hello all, I am new to VB.NET and I have created and openned a recordset. I have the data going to a textbox. But I have having a prolbem creating a button to advance to the next record. In the button it says that the recordset has not been declared. And I need to move forward and backward.
Thanks,
Wardell
 
I declare the recordset in the public sub routine below. I created a button and move through the recordset. I am trying to find maybe a data control or something I can use?

Public Sub LoadScreen(ByRef sServer As Object, ByRef sLogin As Object, ByRef sPASSWORD As Object, ByRef sDatabase As Object)
'On Error GoTo errorHandler
Dim strDMISName As String
Dim strDMISNumber As String
Dim sconnstr As String

Dim oconn As ADODB.Connection
oconn = New ADODB.Connection


sconnstr = "driver={SQL Server}; server=" & sServer & "; " & "uid=" & sLogin & "; pwd=" & sPASSWORD & "; database=" & sDatabase
oconn.Open(sconnstr)

Dim xrs As ADODB.Recordset
xrs = New ADODB.Recordset

Dim fld As ADODB.Field


xrs.Open("SELECT * FROM FLOC", oconn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly)

If xrs.BOF And xrs.EOF Then
Exit Sub
End If

xrs.MoveFirst()
xrs.MoveNext()
'Do While Not rs.EOF


Me.TextBox2.Text = xrs.Fields("Interface Code").Value

xrs.MoveNext()


rs.Close()
rs = Nothing

oconn.Close()
oconn = Nothing

Exit Sub

errorHandler:
MsgBox(Err.Description)
End Sub
 
I don't think the CurrencyManager works with ADO, does it? I thought it was ADO.Net only. I agree though that you should look into ADO.Net. It takes a bit of getting used to, but there are lots of great tools in .Net that are not ADO friendly.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
If you're declaring your xrs recordset in your LoadScreen sub, it's scope is local to that sub only. That's why you can't click your button to advance the recordset. move the decleration out of teh LoadScreen sub and make it Public.

--
James
 
Is there anyway to declare the recordset and not make it public and refence it from outside the sub routine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top