troubleshooting Question

Find max Value

Avatar of JoeBo747
JoeBo747 asked on
Visual Basic Classic.NET ProgrammingSQL
23 Comments2 Solutions439 ViewsLast Modified:
Hi Experts

I have an active valid connection to a table and want to return the content of a field. In access I would use a dmax(myfield, mytable). I want to find the value and use it elsewhere. I have tried to achieve this by using:

con.ConnectionString = "Provider=SQLNCLI;" _
            & "Server=(local);" _
            & "Database=customerlink;" _
             & "Integrated Security=SSPI;" _
             & "DataTypeCompatibility=80;" _
             & "MARS Connection=True;"

            Dim mySQL As String, Isql As String
Isql = "SELECT     MAX(dwJobItemId) AS Expr1 FROM(dbo_jobitem)"
            rst = New ADODB.Recordset
            With rst
                .ActiveConnection = con
                .CursorLocation = ADODB.CursorLocationEnum.adUseClient
                .CursorType = ADODB.CursorTypeEnum.adOpenStatic
                .LockType = ADODB.LockTypeEnum.adLockBatchOptimistic
                .Open(Isql)
                MsgBox(rst.Fields("Expr1").Value)

This will not work. What quick solution can I use in vb.net?

Regards,
Joe
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 23 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 23 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros