Last post Feb 18, 2011 03:43 PM by Shuvo Aymon
Feb 18, 2011 10:27 AM|NickyG|LINK
I have a strange problem...
I am programatically adding an SQL SELECT query to my SqlDataSource that my GridView is bound to. If I use the follwing statement it works fine:
SqlDataSource1.SelectCommand = "SELECT APPLICANTS.DATE, APPLICANTS.APPLICANT, APPLICANTS.TELEPHONE, JOB.EMPREFCODE, APPLICANTS.CALLWAV FROM JOB INNER JOIN APPLICANTS ON JOB.EMPREFCODE = APPLICANTS.JOB WHERE (JOB.EMPREFCODE = '" & jCode & "')"
But if I use the following one, the gridview fails to load. The only way that this is different is it uses RTRIM and CAST on one of the fields:
SqlDataSource1.SelectCommand = "SELECT APPLICANTS.DATE, APPLICANTS.APPLICANT, APPLICANTS.TELEPHONE, JOB.EMPREFCODE, RTRIM(CAST(APPLICANTS.CALLWAV As VARCHAR)) FROM JOBLINE.dbo.JOB INNER JOIN JOBLINE.dbo.APPLICANTS ON JOB.EMPREFCODE = APPLICANTS.JOB WHERE (JOB.EMPREFCODE = '" & jCode & "')"
I don't understand why this can be. If I try the statement exactly how it is in the query builder and run it it returns the rows no problem.
Feb 18, 2011 01:23 PM|SGWellens|LINK
Next time, please include the error message if any. Or, exactly what you mean by "not working"
It might be because in your second query, the column you are modifying has no name.
Try giving it the same name as the original:
RTRIM(CAST(APPLICANTS.CALLWAV As VARCHAR)) as CALLWAV
Feb 18, 2011 03:43 PM|Shuvo Aymon|LINK
You may getting problem for follwoing line
try the query with just JOB and see the result. Is there any db named JOBLINE available? Please check it.