Create Parameter Query from C#?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I create a new Parameter Query in Access 2003 from C#.NET?
How do I check if a Parameter Query by name exists in the Access 2003, using
C#.NET?
How do I get the text of an existing Parameter Query in Access 2003, from
C#.NET?
 
Hi,


There are the ugly ways and the dirty ways.

To create a Parameter query, the ugly way it through the connection object
CreateCommand() method, then

command.CommandType = CommandType.Text;
command.CommandText = "... sql statement here..., with a parameter..."


The dirty way is to define a store procedure with an Execute of an SQL
string: "CREATE PROC procName( argName INTEGER) AS ... "


To use it, the ugly way is through the creation of a parameter object,
through CreateParameter() of the command object, and then


param.ParameterName= "name of the parameter";
param.SqlDbType= SqlDbType.whatever;
param.Value= someValue;


The dirty way is to execute, again, an SQL string: "EXEC PROC procName
listOfParam"


( I won't elaborate on how to process the results, that is generally covered
in C# books/texts about databases).



You can check (query) the MSysObjects system table to know if a query
exists, or not.


I have not tried it, but it sounds that the command object CommandText
should be the place where you can read the "text" of the procedure.


You may get much greater details in a C#/ ADO.Net group of discussion. This
ng is dedicated about using Access, the application, or Jet, the database
engine, from within Access.


Hoping it may help,
Vanderghast, Access MVP
 
Back
Top