Solved

Using SQL with an Acess Db

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now