Solved

Using SQL with an Acess Db

Posted on 2008-10-07
1
177 Views
Last Modified: 2012-05-05
Hi Experts,

Please look at the attached code snippet and tell me how I can assign the result of the SQL query to the integer HighScore.
Dim DbConn As OleDbConnection
Dim SQLStr As String
Dim HighScore As Integer
DbConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db1.mdb")
DbConn.Open()
SQLStr = "SELECT TopScore FROM tblResults WHERE TeamID = 1;"
        
HighScore = ???     
DbConn.Close()

Open in new window

0
Comment
Question by:DColin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 22659074
Try this way:
Dim DbConn As OleDbConnection
Dim SQLStr As String
Dim HighScore As Integer
DbConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db1.mdb")
SQLStr = "SELECT TopScore FROM tblResults WHERE TeamID = 1;"
Dim command As New OleDbCommand(SQLStr, DbConn)
DbConn.Open()
HighScore = command.ExecuteScalar()
DbConn.Close()

Open in new window

0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question