Solved

Calling Saved Querys.

Posted on 2016-10-28
3
29 Views
Last Modified: 2016-11-02
Is there a way to call a saved Query in an Access DB from code (VB or C# .NET), and return a DataTable or similar record object?
0
Comment
Question by:HLRosenberger
  • 2
3 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41864475
have you tried to open the saved query as recordset?
0
 
LVL 1

Accepted Solution

by:
HLRosenberger earned 0 total points
ID: 41864505
I found a way:

 Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.JET.oledb.4.0;data source=C:\Gravity Service MDB\Gravity.mdb")

        Dim cmd As New OleDbCommand
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "GetWorkOrder"
        cmd.Parameters.Add("@LocalID", OleDbType.Integer).Value = 35

        Try
            cmd.Connection = con
            con.Open()

            Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)

            Dim dt As New DataTable

            Dim ds As DataSet = New DataSet()
            da.Fill(ds, "WorkOrder")

            dt = ds.Tables("WorkOrder")

            con.Close()
            con.Dispose()

        Catch ex As Exception

        End Try
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 41869873
this works
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

770 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