Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Passing Multiple Paremeters from string to integer using IN clause

Posted on 2012-03-23
2
Medium Priority
?
432 Views
Last Modified: 2012-03-23
I have a query "SELECT NAME FROM TABLE WHERE PKEY IN(@PKEY)".  Seems simple enough, but @PKEY is my problem.  I always get the "unable to convert type varchar to int" message.  I've tried numerous different ways from arrays to arraylist.  What I'm currently trying to pass resembles:  '1,5,9'

I should mention that the data source is for a Telerik report.  Some things I've tried:

Me.dataSource.Parameters("@CHECKS").Value ='" & key & "')  (where key would be:  '1,5,9'

Any help would be greatly appreciated.
0
Comment
Question by:TRA_DEV
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
ingriT earned 2000 total points
ID: 37757434
You can't pass multiple parameter values in one parameter.

You could do it without the parameter;
"SELECT NAME FROM TABLE WHERE PKEY IN(" & key & ")"

Or you should rewrite the code/query to do multiple queries, one for each key.

int[] keys = key.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
for (int index = 0; index < keys.Length; index++)
{
"SELECT NAME FROM TABLE WHERE PKEY = @CHECKS"
Me.dataSource.Parameters("@CHECKS").Value = keys[index]
}
0
 
LVL 13

Expert Comment

by:Rick
ID: 37757709
Look at raghav_khunger's answer to this post.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question