Solved

Using SQL with an Acess Db

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

896 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

14 Experts available now in Live!

Get 1:1 Help Now