0

I am connecting to a database on MySQL to read certain data in a VB.NET Form. I am using MySQLCommand parameters to pass in my data, but have been unable to use the IN query with multiple values in the parameters. Here is my query (with pointers to commands):

SELECT time, method FROM test1 WHERE custPin=@CUST AND dataID=@ID AND method IN (@CALLS)

There are upwards of two parameters I need to pass into @CALL, which for examples sake will be test1, test2, test3. These are stored in a list before being looped through and inserted into a string for the parameter, for example we will call testList. Below is my MySQLCommand parameter:

dim testList As String = test1 & " " & test2 & " " & test3
mySQLCommand.Parameters.Add("@CALLS", MySqlDbType.String).Value = testList

I have tried to divide the testList using ,, '<SPACE>', and '', but no dice. When dividing it is putting in random \ into my string.

Is there a better way to use the IN MySQL command with multiple values while using MySQL parameters as above?

SeanS
  • 418
  • 1
  • 6
  • 14
  • Take a look at [this question](http://stackoverflow.com/questions/327274/mysql-prepared-statements-with-a-variable-size-variable-list). It's in PHP, but it is what you are looking for, I think. – bhamby Aug 24 '15 at 12:55
  • @bhamby: this is already closed as a duplicate of that ;) – Tim Schmelter Aug 24 '15 at 12:57
  • @TimSchmelter I'm going to blame the time it took me to type out the comment. It was only a little bit after you closed it that I commented. :) – bhamby Aug 24 '15 at 16:10

0 Answers0