Solved

Calling Saved Querys.

Posted on 2016-10-28
3
19 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 119

Expert Comment

by:Rey Obrero
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

760 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

18 Experts available now in Live!

Get 1:1 Help Now