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
USING PARAMETERS IN A SELECT COMMAND
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
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
On the other hand, you may use ControlParameters to assign the selected item as a parameter without any additional code:
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.
Code: Select all
dsDataSource.SelectParameter["prmPais"] = new PgSqlParameter("prmPais", cboCombo1.SelectedItem.Value);
Code: Select all
http://msdn.microsoft.com/en-us/library/z72eefad.aspx
We support the same way of parameters usage for PgSQLDataSource.