[nfbcs] vb ado code

Ryan Stevens RYSteve at comcast.net
Fri Apr 10 01:58:54 UTC 2009


Hello, Bryan,

I replied to  you while I was at work, but I don't think the e-mail got
through.  Just in case, here is the code to open the table in VB ADO 6.0:

Set rs As new ADODB.Recordset
Rs.Open SqlLine, DbConn, adOpenDynamic, adLockOptimistic

Ryan Stevens


-----Original Message-----
From: nfbcs-bounces at nfbnet.org [mailto:nfbcs-bounces at nfbnet.org] On Behalf
Of Bryan Schulz
Sent: Wednesday, April 08, 2009 11:57 PM
To: NFBnet NFBCS Mailing List
Subject: [nfbcs] vb ado code

hi,

I'd like to know if anybody on here is familiar with visual basic 6.0 and
coding access database ado commands.
i have a program working with dow style code and an access '97 database and
am trying to update it to xp and ado code.
The problem is with using an unfamiliar method of coding how to open a
table.


Private Sub LoadTeams()
'load the competing teams from the database 'Dim our variables 'Create
bridge to data Dim DbPath As String Dim DbConn As ADODB.Connection Dim RS As
ADODB.Recordset Dim sqlLine As String Dim Game As Integer Dim i As Integer
Dim iRecs As Integer

'find the database
DbPath = App.Path
If Right$(DbPath, 1) <> "\" Then DbPath = DbPath & "\"
DbPath = DbPath & "BB-tourney.mdb"

' Open a connection.
Set DbConn = New ADODB.Connection
DbConn.ConnectionString = _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & DbPath & ";" & _
    "Persist Security Info=False"
DbConn.Open

sqlLine = sqlLine & "SELECT * FROM "
sqlLine = sqlLine & "all_2004_teams"
sqlLine = sqlLine & " ORDER BY game_code"
'MsgBox "sql line = " & sqlLine, vbOKOnly, "sql check"

' Get the records
'** problem **
Set RS = DbConn.Execute(sqlLine, , adCmdText) 'It complains about missing
parameters 'The second parameter is how many records are affected and is
optional 'Anyone recognize what it should say?

'Get the teams from the database
i = 0
For Game = 1 To 8
    optTeam(i).Caption = RS.Fields("team_a").Value
    i = i + 1
    optTeam(i).Caption = RS.Fields("team_b").Value
    i = i + 1
    RS.MoveNext
Next Game

'Close the connection
DbConn.Close
Set DbConn = Nothing
End Sub

Bryan Schulz
The BEST Solution
www.best-acts.com
_______________________________________________
nfbcs mailing list
nfbcs at nfbnet.org
http://www.nfbnet.org/mailman/listinfo/nfbcs_nfbnet.org
To unsubscribe, change your list options or get your account info for nfbcs:
http://www.nfbnet.org/mailman/options/nfbcs_nfbnet.org/rysteve%40comcast.net





More information about the NFBCS mailing list