?
=?ISO-8859-1?Q?Roland_M=FCller?=
Hi Ng,
i have a sucking problem......
select * from test where nId IN (1, 2, 3)
Now i want to execute this with an sqlcommand and more interesting with
an sqlParameter:
sqlCommand.CommandText = select * from test where nId in (@IN-Values)";
I first tried:
SqlParameter sqlParameter = new SqlParameter("@Values", "1, 2, 3");
Exeption: Syntax error converting the nvarchar value '1, 2, 3' to a
column of data type int
This is very logical. But how can i do?
I then tried to use an int32 array or an arraylist with int values:
int[] test = new Int32[] {1, 2, 3};
ArrayList test2 = new ArrayList();
test2.Add(1);
test2.Add(2);
SqlParameter sqlParameter = new SqlParameter("@Values", test);
SqlParameter sqlParameter = new SqlParameter("@Values", test2);
This didn't work, too. I cannot give an array or arraylist to a
parameter as value.
How can i resolve my problem? I don't want to do without sqlparameter
and i only want ONE sqlparameter! Is it impossible?
Thanks,
Roland
i have a sucking problem......
select * from test where nId IN (1, 2, 3)
Now i want to execute this with an sqlcommand and more interesting with
an sqlParameter:
sqlCommand.CommandText = select * from test where nId in (@IN-Values)";
I first tried:
SqlParameter sqlParameter = new SqlParameter("@Values", "1, 2, 3");
Exeption: Syntax error converting the nvarchar value '1, 2, 3' to a
column of data type int
This is very logical. But how can i do?
I then tried to use an int32 array or an arraylist with int values:
int[] test = new Int32[] {1, 2, 3};
ArrayList test2 = new ArrayList();
test2.Add(1);
test2.Add(2);
SqlParameter sqlParameter = new SqlParameter("@Values", test);
SqlParameter sqlParameter = new SqlParameter("@Values", test2);
This didn't work, too. I cannot give an array or arraylist to a
parameter as value.
How can i resolve my problem? I don't want to do without sqlparameter
and i only want ONE sqlparameter! Is it impossible?
Thanks,
Roland