.NET Framework Class Library
Database.ExecuteQuery Method (String, IDictionary)

<< Click to Display Table of Contents >>

Navigation:  MwPDMApi Namespace > Database Class > Database Methods > ExecuteQuery Method  >

.NET Framework Class Library
Database.ExecuteQuery Method (String, IDictionary)

Executes a query against the database, with the specified parameters. The query must be a valid SQL command that can be executed against the database. It does not return any result, it is used for commands like INSERT, UPDATE, DELETE, etc.

Namespace: MwPDMApi
Assembly:  MwPDMApi (in MwPDMApi.dll) Version: 1.0.0.0 (1.0.0.0)

Syntax

Visual Basic

Public Sub ExecuteQuery ( _

 query As String, _
 parameters As IDictionary _
)

C#

public void ExecuteQuery(

 string query,
 IDictionary parameters
)

Visual C++

public:

void ExecuteQuery(
 String^ query,
 IDictionary^ parameters
)

JavaScript

function executeQuery(query, parameters);

Parameters

query

Type: System.String
The SQL query to execute.

parameters

Type: System.Collections.IDictionary
A dictionary of parameters to use in the query.

Remarks

The query is a standard parameterized query like

 

Copy imageCopy Code

INSERT INTO DOCUMENT (ID, DESCRIPTION, CREATION_DATE) VALUES (@id, @description, @creationdate)

 

The parameters dictionary must contain the parameter names and values, without the '@' symbol. For example:

 

Copy imageCopy Code

 Dim parameters As New Dictionary(Of String, Object)()

 parameters("id") = 1

 parameters("description") = "Sample Description"
 parameters("creationdate") = DateTime.Now

 

Or in PowerShell:

 

Copy imageCopy Code

 $parameters = @{

     id = 1

     description = "Sample Description"
     creationdate = [datetime](Get-Date)
 }

The format of the query and the parameters is the standard one for parameterized queries in ADO.NET, with '@' as prefix for parameters in the query, and a dictionary of parameter names and values passed to the method. The parameters type are inferred automatically and correctly managed in most of the standard scenarios.

See Also

Database Class

Database Members

ExecuteQuery Overload

MwPDMApi Namespace