Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

Need help with an SQL query and creating Variables for my application??
Right now I'm filling my dataset by adding a query to my tableadapter
and filling by a specific field value in my ADO.net program.  I would
also like to come up with some way to replace the Specific Field "Desk"
in my code and place a variable in there that can be replaced with
anything.

Select * from DataTable Where (Desk = @DeskValue)  ' and I name this
query works great.

Select * from DataTable Where (@Field = @Value) 'This doesn't work for
me, but want to know if there is another way to do this?


Report this thread to moderator Post Follow-up to this message
Old Post
mike11d11
12-13-06 05:13 AM


Re: Need help with an SQL query and creating Variables for my application??
mike

Since I don't know  your business logic behind it , I can only guess

declare @sql nvarchar(1000),
@col  sysname,
@orderid int

select @col='OrderID', @orderid=10248

set @sql = 'select * from Northwind..Orders where '+@col+'= @ordid'
exec sp_executesql @sql, N'@ordid int',@orderid







"mike11d11" <mike11d11@yahoo.com> wrote in message
news:1165985467.864390.301360@80g2000cwy.googlegroups.com...
> Right now I'm filling my dataset by adding a query to my tableadapter
> and filling by a specific field value in my ADO.net program.  I would
> also like to come up with some way to replace the Specific Field "Desk"
> in my code and place a variable in there that can be replaced with
> anything.
>
> Select * from DataTable Where (Desk = @DeskValue)  ' and I name this
> query works great.
>
> Select * from DataTable Where (@Field = @Value) 'This doesn't work for
> me, but want to know if there is another way to do this?
>



Report this thread to moderator Post Follow-up to this message
Old Post
Uri Dimant
12-13-06 10:18 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 10:17 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006