Hi, I have Error when I write this SQL statement retrieving the non selected facilitator for a specific course:
The SQL statement:
SELECT facilitators.facilitator_id, facilitators.facilitator_name
FROM facilitators INNER JOIN
[transaction_ facilitators] ON facilitators.facilitator_id <> [transaction_ facilitators].trans_Facilitator_id
WHERE (NOT (facilitators.facilitator_id IN
(SELECT [transaction_ facilitators].trans_Facilitator_id
FROM [transaction_ facilitators]
WHERE [transaction_ facilitators].trans_Course_id = 2)))
GROUP BY facilitators.facilitator_id, facilitators.facilitator_name
ORDER BY facilitators.facilitator_id
Every thing goes right until I change this:
WHERE [transaction_ facilitators].trans_Course_id = 2
To
WHERE [transaction_ facilitators].trans_Course_id = @.course_id
It gives me this error:
Incorrect syntax near the keyword "From"
Any suggestion ??
Will it give the error before it takes the value.
:( I don't know what to do..
Its not working its sth with the passing parameter.
HELP…
The " Incorrect syntax near the keyword "From" error is appear to me while im using the query builder .
The error while using the code appears to be :
Invalid index 0 for this SqlParameterCollection with Count=0.
And the cose id:
IfNot Page.IsPostBackThen
Me.SqlConn.Open()
Me.SqlDataAdapter_Get_FaciliInfo.SelectCommand.Parameters(0).Value = 1'Request.QueryString.Get("courseid")
Me.SqlDataAdapter_Get_FaciliInfo.Fill(Me.Dataset_Get_PopUpFaciliInfo)
Me.DataGrid_Get_Info.DataBind()
Me.SqlConn.Close()
EndIf
...
|||
no its not that if you've noticed that i make it comment
Me.SqlDataAdapter_Get_FaciliInfo.SelectCommand.Parameters(0).Value = 1'Request.QueryString.Get("courseid")
And pass the parameter a value 1 and I still get the same error
|||ok let's try one more time is the following your query string for your commandtext?:SELECT facilitators.facilitator_id,facilitators.facilitator_name
FROM facilitatorsINNER JOIN
[transaction_facilitators] ON facilitators.facilitator_id <> [transaction_facilitators].trans_Facilitator_id
WHERE (NOT(facilitators.facilitator_id IN
(SELECT [transaction_facilitators].trans_Facilitator_id
FROM [transaction_facilitators]
WHERE [transaction_facilitators].trans_Course_id = @.code_id)))
GROUP BY facilitators.facilitator_id,facilitators.facilitator_name
if so, change the @.code_id to ?(question mark) so that the resulting command text will be:
SELECT facilitators.facilitator_id,facilitators.facilitator_name
FROM facilitatorsINNER JOIN
[transaction_facilitators] ON facilitators.facilitator_id <> [transaction_facilitators].trans_Facilitator_id
WHERE (NOT(facilitators.facilitator_id IN
(SELECT [transaction_facilitators].trans_Facilitator_id
FROM [transaction_facilitators]
WHERE [transaction_facilitators].trans_Course_id = ?)))
GROUP BY facilitators.facilitator_id,facilitators.facilitator_name
ORDER BY facilitators.facilitator_id
the reason being the @.<var> is a sql server reserved naming convention for its variable, it(Sql) assumed then that you declare a variable of that name, however since it isn't declared(coz it is being passed) it doesn't know how to generate a plan and gives you a cryptic error in FROM..
:( That's unbelievable… its not working what is this… look I try this:
SELECT DISTINCT facilitators.facilitator_id, facilitators.facilitator_name
FROM facilitators INNER JOIN
[transaction_ facilitators] ON facilitators.facilitator_id <> [transaction_ facilitators].trans_Facilitator_id
WHERE (NOT (facilitators.facilitator_id IN
(SELECT [transaction_ facilitators].trans_Facilitator_id
FROM [transaction_ facilitators]
WHERE [transaction_ facilitators].trans_Course_id = @.course_id)))
ORDER BY facilitators.facilitator_id
Not Working the same error: "Incorrect syntax near the keyword "From"
"
And I try this:
SELECT DISTINCT facilitators.facilitator_id, facilitators.facilitator_name
FROM facilitators INNER JOIN
[transaction_ facilitators] ON facilitators.facilitator_id <> [transaction_ facilitators].trans_Facilitator_id
WHERE (NOT (facilitators.facilitator_id IN
(SELECT [transaction_ facilitators].trans_Facilitator_id
FROM [transaction_ facilitators]
WHERE [transaction_ facilitators].trans_Course_id = @.course_id)))
GROUP BY facilitators.facilitator_id, facilitators.facilitator_name
ORDER BY facilitators.facilitator_id
Not Working the same error: "Incorrect syntax near the keyword "From"
"
And I try this:
SELECT facilitators.facilitator_id, facilitators.facilitator_name
FROM facilitators INNER JOIN
[transaction_ facilitators] ON facilitators.facilitator_id <> [transaction_ facilitators].trans_Facilitator_id
WHERE (NOT (facilitators.facilitator_id IN
(SELECT [transaction_ facilitators].trans_Facilitator_id
FROM [transaction_ facilitators]
WHERE [transaction_ facilitators].trans_Course_id = ?)))
GROUP BY facilitators.facilitator_id, facilitators.facilitator_name
ORDER BY facilitators.facilitator_id
Not Working the same error: "Incorrect syntax near the keyword "From"
"
And I try this:
SELECT facilitators.facilitator_id, facilitators.facilitator_name
FROM facilitators INNER JOIN
[transaction_ facilitators] ON facilitators.facilitator_id <> [transaction_ facilitators].trans_Facilitator_id
WHERE (NOT (facilitators.facilitator_id IN
(SELECT [transaction_ facilitators].trans_Facilitator_id
FROM [transaction_ facilitators]
WHERE [transaction_ facilitators].trans_Course_id = ?)))
ORDER BY facilitators.facilitator_id
Not Working the same error: "Incorrect syntax near the keyword "From"
"
Nothing work what is this… is it a curse ?
I don't have more time :'(… HELP
This error message would have an uppercase FROM if it were being generated from the code you have supplied so far.
Incorrect syntax near the keyword "From"I think you are looking in the wrong place for the code generating the error.
sql
No comments:
Post a Comment