USING PARAMETERS IN A SELECT COMMAND

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
JORGEMAL
Posts: 171
Joined: Thu 03 Jul 2008 23:55

USING PARAMETERS IN A SELECT COMMAND

Post by JORGEMAL » Tue 19 Jan 2010 23:28

This is the first time that I use parameters in a SELECT command and I need help.

I have a datasource with the following SELECT command:
------------------------------------------------------------------------------
SelectCommand="SELECT fan_clave, fan_nombre, fan_dir
FROM cat_clubs_fans, cat_paises, cat_artistas
WHERE fan_pais = :prmPais AND fan_artista = :prmArtista AND
fan_artista = art_clave AND fan_pais = pss_clave
ORDER BY fan_nombre"





------------------------------------------------------------------------------

My web form has 2 comboboxes and the parameters' values will depend on their values; the comboboxes' values are Int32 both.

How do I set the paprameters' values?
I tried the following:

dsDataSource.SelectParameter["prmPais"] = cboCombo1.SelectedItem.Value;
dsDataSource.SelectParameter["prmArtista"] = cboCombo2.SelectedItem.Value;

but I get a message saying "Cannot implicitly convert type 'object' to 'System.Web.UI.WebControls.Parameter'".

Please advice.
With respect,
Jorge Maldonado

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Wed 20 Jan 2010 12:20

In the sample you are assigning the string value to the parameter object. To assign this value to the select parameter, you should create the PgSqlParameter object. This would be something like

Code: Select all

dsDataSource.SelectParameter["prmPais"] = new PgSqlParameter("prmPais", cboCombo1.SelectedItem.Value);
On the other hand, you may use ControlParameters to assign the selected item as a parameter without any additional code:

Code: Select all

 
	 
	 

For more information on this, please refer to the MSDN documentation:
http://msdn.microsoft.com/en-us/library/z72eefad.aspx
We support the same way of parameters usage for PgSQLDataSource.

Post Reply