Anyname Donotcare
Anyname Donotcare

Reputation: 11403

about parameterized query

Q:

Please , i want to ask ,how to perform a query(select statement) using a parametrized query in Informix database ,with a simple example. thanks in advance.

EDIT:

i use

IfxConnection and IfxCommand

Upvotes: 1

Views: 283

Answers (1)

user240141
user240141

Reputation:

.NET Framework Data Provider for OLE DB

This is just one connection string sample for the wrapping OleDbConnection class that calls the underlying OLEDB provider. See respective OLE DB provider for more connection strings to use with this class.

Provider=Ifxoledbc;Data Source=dbName@serverName;User ID=myUsername;Password=myPassword;

 public void CreateMyOleDbCommand(OleDbConnection connection,
    string queryString, OleDbParameter[] parameters) 
{
    OleDbCommand command = new OleDbCommand(queryString, connection);
    command.CommandText = 
        "SELECT CustomerID, CompanyName FROM Customers WHERE Country = ? AND City = ?";
    command.Parameters.Add(parameters);

    for (int j=0; j<parameters.Length; j++)
    {
        command.Parameters.Add(parameters[j]) ;
    }

    string message = "";
    for (int i = 0; i < command.Parameters.Count; i++) 
    {
        message += command.Parameters[i].ToString() + "\n";
    }
    Console.WriteLine(message);
}

Hope this will help

Upvotes: 2

Related Questions