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?

3
  • Take a look at this question. It's in PHP, but it is what you are looking for, I think. Commented Aug 24, 2015 at 12:55
  • @bhamby: this is already closed as a duplicate of that ;) Commented Aug 24, 2015 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. :) Commented Aug 24, 2015 at 16:10

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.