missing parameter dataset error

missing parameter dataset error

Postby andopo » Tue 09 Jan 2007 11:51

Hello
i have a situation like this:

protected void Page_Load(object sender, EventArgs e)
{
string connString = WebConfigurationManager.ConnectionStrings["TESTConnectionString"].ConnectionString;
PgSqlConnection con = new PgSqlConnection(connString);

string sql = "SELECT * FROM users WHERE id_org = :id_org";

PgSqlCommand cmd = new PgSqlCommand(sql, con);
con.Open();
PgSqlParameter param = new PgSqlParameter();
param.ParameterName = "id_org";
param.PgSqlType = PgSqlType.Int;
// just an example value
param.Value = 3;

PgSqlDataAdapter da = new PgSqlDataAdapter(sql, con);
DataSet ds = new DataSet();

da.Fill(ds, "users");
con.Close();

GridView1.DataSource = ds;
GridView1.DataBind();
}

I get a message: Parameter 'id_org' is missing

What is wrong?

Andrzej
andopo
 
Posts: 3
Joined: Tue 09 Jan 2007 11:47

Postby Alexey » Tue 09 Jan 2007 15:26

You should add the following string before calling Fill() method:
Code: Select all
da.SelectCommand.Parameters.Add(param);
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43


Return to dotConnect for PostgreSQL