Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 682
  • Last Modified:

Passing a query string to a table adapter

In a stored procedure, you can pass a query string and just execute it...

Exec(@SqlCommand)

When creating a table adapter query, is there a way to run a query string you pass in?

Thanks.
0
Starr Duskk
Asked:
Starr Duskk
  • 4
1 Solution
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
Instead of Exec(@SqlCommand)

try using

declare @sql nvarchar(1000);
set @sql = N'select * from urtable where col1 = @var);
exec sp_executesql @sql, @var = @IntVariable

This will do..
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
We're talking about a table adapter query?
It errors that the Declare Sql Construct or statement is not supported.
 
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
How do I use this? What am I missing?
 It errors that the Declare Sql Construct or statement is not supported.
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
I'd like to pass in my querystring, so I've also tried this:
exec sp_executesql @SQLString
Errors exec statement isn't supported.
How do I get this to work?
thanks.
 
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
well, I never got an answer on how to implement this. But I'm going to close it out.
 
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now