[nfbcs] vb ado code

Bryan Schulz b.schulz at sbcglobal.net
Fri Apr 10 19:04:11 UTC 2009


hi,

i got it with suggestions from a specific list.
i'll send you the code if you want since there is low interest on here.

Bryan Schulz
The BEST Solution
www.best-acts.com

----- Original Message ----- 
From: "Ryan stevens" <rysteve at comcast.net>
To: "'NFBnet NFBCS Mailing List'" <nfbcs at nfbnet.org>
Sent: Thursday, April 09, 2009 10:24 AM
Subject: Re: [nfbcs] vb ado code


> Hello, Bryan,
>
> Below is what I did to read data from an Access database for an import
> application I wrote in VB 6.0.  I will tell you that i tried to convert it
> into VB.net 2005 some time ago, so I'm not 100% sure this is what it was
> originally, but it's worth a shot.  Before I list it though, I noticed 
> that
> your first line for setting the text in your SqlLine variable reads 
> 'SqlLine
> = SqlLine & "SELECT * FROM"'.  I don't think you need the 'SqlLine &' for
> this line of code.  Anyway, here's what I have with the variables changed 
> to
> match yours:
>
> rs = New ADODB.Recordset
> rs.Open(SqlLine, DbConn, ADODB.CursorTypeEnum.adOpenDynamic,
> ADODB.LockTypeEnum.adLockOptimistic)
>
> Hope this helps,
> 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
>
> _______________________________________________
> 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/b.schulz%40sbcglobal.net 





More information about the NFBCS mailing list