Solved

Using SQL with an Acess Db

Posted on 2008-10-07
1
175 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
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 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