Parameter Array

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
sportsoft
Posts: 4
Joined: Wed 20 Feb 2008 05:35

Parameter Array

Post by sportsoft » Thu 21 Feb 2008 06:40

Hi All

I have the following data adapter selectcommand:

SELECT * FROM game_type WHERE game_type_id IN (@game_type_list) AND (deleted=0) ORDER BY game_type_name asc

I want to pass an array to this list with comma separated values ie

Code: Select all

MySqlDataAdapter_game_type.SelectCommand.Parameters.Add("@game_type_list", CoreLab.MySql.MySqlType.BigInt, 20).Value = "1,2,3"
Obviously, this does not work as its passing a string to a int type, but I cant use varchar type either as this is an int type column in the table.

The SQL query that I am trying to replicate would look like this:

SELECT * FROM game_type WHERE game_type_id IN (1,2,3) AND (deleted=0) ORDER BY game_type_name asc

How can I do this with a parameter?

Nick

Alexey.mdr
Posts: 729
Joined: Thu 13 Dec 2007 10:24

Post by Alexey.mdr » Thu 21 Feb 2008 12:19

It does not matter what types you are passing.
Because it's a SELECT statement, it is being passed to the server as string type.
Will this block of code make it work?

Code: Select all

---
SELECT * FROM game_type WHERE game_type_id IN (@game_type_list) AND (deleted=0) ORDER BY game_type_name asc;
--- 
    
string arrVal = "1,2,3";
MySqlDataAdapter_game_type.SelectCommand.Parameters.Add("game_type_list", arrVal);

Post Reply