Click here to Skip to main content
16,011,578 members
Home / Discussions / Database
   

Database

 
AnswerRe: How can I set the output format of "FOR XML"? Pin
Tushar Kothari11-Sep-06 3:51
Tushar Kothari11-Sep-06 3:51 
QuestionHow to install the Postgre SQL using Silent Mode in Windows 2000? Pin
Arul Joseph8-Sep-06 0:52
Arul Joseph8-Sep-06 0:52 
Questionxp_smtp_sendmail/xpsmtp80.dll Pin
Arghya_mp7-Sep-06 23:55
Arghya_mp7-Sep-06 23:55 
QuestionRegarding Cursor Pin
param thaker7-Sep-06 23:05
param thaker7-Sep-06 23:05 
AnswerRe: Regarding Cursor Pin
Stephen McGuire8-Sep-06 9:23
Stephen McGuire8-Sep-06 9:23 
QuestionDatabase for Java [modified] Pin
eMtek7-Sep-06 20:33
eMtek7-Sep-06 20:33 
AnswerRe: Database for Java Pin
Dominic Pettifer8-Sep-06 2:36
Dominic Pettifer8-Sep-06 2:36 
QuestionParameterized Queries in the SELECT portion? Pin
Dominic Pettifer7-Sep-06 13:51
Dominic Pettifer7-Sep-06 13:51 
I'm having problems with Parameterized Queries. The problem seems to occur when I use them in the SELECT portion of the SQL statement. Note the following code...

string sql = "SELECT TOP @NumberOfBlogs blgID, blgShortName, blgLongName, blgDatePosted " +
	     "FROM tblBlogs " +
	     "WHERE blgEnabled = 1";

SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add(new SqlParameter("@NumberOfBlogs", 3));


This throws an SQLException "Incorrect syntax near '@NumberOfBlogs'.". However, if I change it and use a Parameterized Query in another part of the statement such as the where clause, it works fine. For instance...

string sql = "SELECT TOP 3 blgID, blgShortName, blgLongName, blgDatePosted " +
	     "FROM tblBlogs " +
	     "WHERE blgEnabled = @IsEnabled";

SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add(new SqlParameter("@IsEnabled", 1));


...this code runs fine. Am I right in understanding that you can't use Parameterized Queries in the SELECT portion of the SQL statement? Or is there something I'm not doing right? Will I have to fall back on string concatenation instead? Many thanks!

Sunday Ironfoot

www.dominicpettifer.co.uk (work in progress)

AnswerRe: Parameterized Queries in the SELECT portion? Pin
Not Active7-Sep-06 18:53
mentorNot Active7-Sep-06 18:53 
GeneralRe: Parameterized Queries in the SELECT portion? Pin
Dominic Pettifer8-Sep-06 2:31
Dominic Pettifer8-Sep-06 2:31 
GeneralRe: Parameterized Queries in the SELECT portion? Pin
Colin Angus Mackay10-Sep-06 9:27
Colin Angus Mackay10-Sep-06 9:27 
Questionupdating an IMAGE column Pin
jszpila7-Sep-06 5:15
jszpila7-Sep-06 5:15 
AnswerRe: updating an IMAGE column Pin
Michael Potter7-Sep-06 5:50
Michael Potter7-Sep-06 5:50 
Questioncombining multiple rows into single column Pin
Uma Kameswari7-Sep-06 2:32
Uma Kameswari7-Sep-06 2:32 
AnswerRe: combining multiple rows into single column Pin
Michael Potter7-Sep-06 6:02
Michael Potter7-Sep-06 6:02 
AnswerRe: combining multiple rows into single column Pin
Eric Dahlvang7-Sep-06 9:26
Eric Dahlvang7-Sep-06 9:26 
Questionfunction vs stored procedure in sqlserver 2000 Pin
yazan_zahi7-Sep-06 1:42
yazan_zahi7-Sep-06 1:42 
AnswerRe: function vs stored procedure in sqlserver 2000 Pin
SeMartens7-Sep-06 1:52
SeMartens7-Sep-06 1:52 
AnswerRe: function vs stored procedure in sqlserver 2000 Pin
saqib827-Sep-06 4:29
saqib827-Sep-06 4:29 
AnswerRe: function vs stored procedure in sqlserver 2000 Pin
Sumitjh8213-Sep-06 20:02
Sumitjh8213-Sep-06 20:02 
QuestionHow would i query these tables? Pin
Red_Wizard_Shot_The_Food7-Sep-06 0:15
Red_Wizard_Shot_The_Food7-Sep-06 0:15 
AnswerRe: How would i query these tables? Pin
SeMartens7-Sep-06 1:48
SeMartens7-Sep-06 1:48 
AnswerRe: How would i query these tables? Pin
Mike Dimmick7-Sep-06 2:13
Mike Dimmick7-Sep-06 2:13 
GeneralRe: How would i query these tables? Pin
Red_Wizard_Shot_The_Food7-Sep-06 22:55
Red_Wizard_Shot_The_Food7-Sep-06 22:55 
QuestionC# DataSet DataAdapter Design Pin
llap4446-Sep-06 5:03
llap4446-Sep-06 5:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.