472,378 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,378 software developers and data experts.

Retrieve Stored proc name

what is a common method, if any, to retrieve stored query information
from Access. MDAC does not support OleDbSchemaGuid.Procedure_Columns. I
need stored procedure name and paramter information, can you get this?

Nov 13 '05 #1
11 2541
If you are in Access you can do this:

Sub GetQryInfo()
Dim DB As Database, QD As QueryDef, str1 As String
Set DB = CurrentDB
For Each QD In DB.QueryDefs
Debug.Print QD.Name
Debug.Print QD.Sql
Next
End Sub

This will print out the names of all the queries in an Access mdb and
will also print out the sql string inside each query. If you are doing
this from a VB6 app, then just make a reference to the Microsoft Access
Object Library. You can then use

Dim app As Access.Application
Set app = CreateObject("Access.Application")
or
Set app = GetObject(, "Access.Application") if Access is already running

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #2
pap
Not sure that will retrieve stored procedures from a server.

peter walker

"Rich P" <rp*****@aol.com> wrote in message news:42**********@127.0.0.1...
If you are in Access you can do this:

Sub GetQryInfo()
Dim DB As Database, QD As QueryDef, str1 As String
Set DB = CurrentDB
For Each QD In DB.QueryDefs
Debug.Print QD.Name
Debug.Print QD.Sql
Next
End Sub

This will print out the names of all the queries in an Access mdb and
will also print out the sql string inside each query. If you are doing
this from a VB6 app, then just make a reference to the Microsoft Access
Object Library. You can then use

Dim app As Access.Application
Set app = CreateObject("Access.Application")
or
Set app = GetObject(, "Access.Application") if Access is already running

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #3
jw*****@gmail.com wrote in news:1109711904.529069.185500
@f14g2000cwb.googlegroups.com:
what is a common method, if any, to retrieve stored query information
from Access. MDAC does not support OleDbSchemaGuid.Procedure_Columns. I
need stored procedure name and paramter information, can you get this?


You can get the ID and Name of SQL procedures with a T-SQL string like this.

"SELECT ID, name FROM SysObjects WHERE xtype='P'"

You can use the IDs returned to get the T-SQL of the Sprocs
with

"SELECT text FROM SysComments WHERE ID=" & ID

this assumes you have permissions and some programming ability.
Nov 13 '05 #4
jw*****@gmail.com wrote:
what is a common method, if any, to retrieve stored query information
from Access. MDAC does not support OleDbSchemaGuid.Procedure_Columns. I
need stored procedure name and paramter information, can you get this?


BOL: sp_helptext

--
This sig left intentionally blank
Nov 13 '05 #5
Wasn't sure if you wanted queryDef info or SP info from Sql Server.
Here is how to get SP info from Sql Server from Access

Make a reference to Microsoft SQLDMO object Library then

Sub GetSPList()
Dim oSqlSrv As SQLDMO.SQLServer
Dim sp As SQLDMO.StoredProcedure
Dim Sps As SQLDMO.StoredProcedures
Dim i As Integer, j As Integer
Dim str1 As String, str2 As String

Set oSqlSrv = New SQLDMO.SQLServer
'--set to false for Sql Server Authentication
oSqlSrv.LoginSecure = False
oSqlSrv.Connect "yourSqlServer", "sa", "password"

Set Sps = oSqlSrv.Databases("yourSqlDB").StoredProcedures
For Each sp In Sps
If sp.SystemObject = False Then
Debug.Print sp.Name
Debug.Print sp.Script
End If
Next
End Sub

This will work remotely from Access from a workstation where your SQl SB
does not reside on the same computer. The only catch is that you have
to have the Microsoft SQLDMO object library loaded on that workstation
for this code to run (and, of course, permissions, etc).

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #6
so how would this be done through ado.net?

Nov 13 '05 #7
jw*****@gmail.com wrote:
so how would this be done through ado.net?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Here's a C# example from _ADO.NET in a Nutshell_; pub: O'Reilly:

using System;
using System.Data.SQLClient;

public class GetRoutineList
{
public static void Main()
{
// Set up connection to SQL Server sample DB "Northwind"
string connectionString = "Data Source=localhost;" +
"Initial Catalog=Northwind;Integrated Security=SSPI";
string SQL = "SELECT ROUTINE_TYPE, ROUTINE_NAME FROM " +
"INFORMATION_SCHEMA.ROUTINES";

// Create ADO.NET objects
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(SQL, con);
SqlDataReader r;

// Execute the query
try
{
con.Open();
r = cmd.ExecuteReader();
while (r.Read())
{
Console.WriteLine(r[0] + ": " + r[1]);
}
}
finally
{
con.Close();
}
}
}

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQjYSUIechKqOuFEgEQKBZACeLZxPLgQ70WoiFoS6/vgb99XcLtUAn2Zt
yNO/M6Au4Uzmpf/cUJM37ftv
=knO8
-----END PGP SIGNATURE-----
Nov 13 '05 #8
I believe SQLDMO is the only way to get DB info from Sql Server (2000)
from an external app. I only run the sp's from ADO.Net. Anyway, SqlDMO
is com based. So even if you are in a VB.Net/C# app, you still have to
make a com reference to SqlDMO. Matter of fact, since SqlDMO is com
based, I don't think ADO.Net has any features for extracting info from
Sql Server. Maybe ADO.Net2 can do SqlDMO stuff with Sql Server2005
(Yukon is it?). But ADO.Net2 is way off, next year maybe (I am
anxiously waiting).

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #9
But how is this done for Access?
Let me clarify: How do you retrieve the stored queries( as in the
names, sql, and parameter information) from a MDB file in asp.net using
c# or vb.net? Its easy to do in SQL server, but is it possible in a MDB
file.

Nov 13 '05 #10
jw*****@gmail.com wrote:
But how is this done for Access?
Let me clarify: How do you retrieve the stored queries( as in the
names, sql, and parameter information) from a MDB file in asp.net using
c# or vb.net? Its easy to do in SQL server, but is it possible in a MDB
file.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I tried this on my system & was able to see the Tables & Procedures
schemas. There's supposed to be a OleDbSchemaGuid.Views, but I got an
error when I tried it. In the Views schema table there is a
VIEW_DEFINITION column that holds the SQL. Perhaps the JET 4.0 engine
can't provide this information.

According to my ADO reference manual, SELECT queries are Views and
action and crosstab queries are Procedures.
=== begin C# code ===
using System;
using System.Data;
using System.Data.OleDb;

public class GetSchema
{
public static void Main()
{
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Data Source=C:\Documents and Settings\Owner\My Documents" +
@"\Databases\MyDatabases\AccessXP\TestBed.mdb";
// Create ADO.NET objects
OleDbConnection con = new OleDbConnection(connectionString);

DataTable schema;

// Execute the query
try
{
con.Open();
// Use OleDbSchemaGuid.Procedures to get Action queries
schema = con.GetOleDbSchemaTable(OleDbSchemaGuid.Procedures ,
new object[] {null, null, null, null});
}
finally
{
con.Close();
}

// Display the schema table.
if (schema != null)
foreach (DataRow row in schema.Rows)
{
// For tables/Views use the following
/* Console.WriteLine(row["TABLE_TYPE"] + ": " +
row["TABLE_NAME"]) ;
*/
// For Procedures use the following
Console.WriteLine(row["PROCEDURE_NAME"] + ":\n" +
row["PROCEDURE_DEFINITION"]);

}
}
}
=== end code ===

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQji0jIechKqOuFEgEQJrFwCgt1eE6UY6STEaH5Y1PemRYb 4IigIAoPcY
b+h4bqf4BHAFhx9rbl5ZXkJm
=zIqC
-----END PGP SIGNATURE-----
Nov 13 '05 #11
I had done that and yes JET 4.0 engine does not provide this
information. so im out of luck, oh well.

Nov 13 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: xAvailx | last post by:
I have a requirement that requires detection of rows deleted/updated by other processes. My business objects call stored procedures to create, read, update, delete data in a SQL Server 2000 data...
4
by: Learner | last post by:
Hi there, I have a storec proc that schedules a Sql job and finally it returns 0 then it was successfull and if it returns 1 then its unsuccessful. Now when i run the stored proc in the query...
6
by: Paul M | last post by:
Hi All, I'm currently writing a z/OS DB2 Stored Proc in C, using an example from the IBM Stored Procedure guide (SG24-7083-00). The database calls to read and update the database work...
4
by: hicks | last post by:
I'm trying to invoke a DB2 stored procedure. The stored proc is coded in C and compiled to a shared library, which has been placed in the <DB2 dir>/functions directory. The platform is Solaris....
3
by: Fran | last post by:
(SQL 2005) I'm looking to create a stored procedure to first "select name from sys.databases where name like '%site'" then pass each name to the following using some kind of loop "USE @name select...
0
by: ravindrag | last post by:
Hi, I am getting error SQL1131N during sqlj.install_jar(...). There is no useful message in the diag.log (even with diag level 4). I am giving the diag.log entries at the end of this posting...
0
by: db2user24 | last post by:
I'm trying to invoke a DB2 stored procedure. The stored proc is coded in C and compiled to a shared library, which has been placed in the <DB2 dir>/functions directory. The platform is Linux (using...
4
by: davinski | last post by:
Hello, it's been a while since my last post, hope everyone is fine :P I'm stuck with what seems to be a simple task, but I'm getting confused on how to complete this. Basically, I have been given...
0
by: mirandacascade | last post by:
Questions toward the bottom of the post. Situation is this: 1) Access 97 2) SQL Server 2000 3) The Access app: a) sets up pass-thru query b) .SQL property of querydef is a string, the...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...
0
by: F22F35 | last post by:
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.