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-----