Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL Query

Author  Topic 

saidev
Posting Yak Master

101 Posts

Posted - 2006-02-14 : 18:51:27
Hi guys,

is there anything wrong with this query..? i am passing "accountid" as parameter. it works fine in the query analyzer when i assign a value.. but it is not working in the application.
any thing wrong with this query..?
Accountid is "string"

Thanks,

sql = "SELECT tblAccountExec.fkOfficeLocation, tblOfficeLocation.fkLSSArea FROM tblAccountExec INNER JOIN tblOfficeLocation ON tblAccountExec.fkOfficeLocation = tblOfficeLocation.pkid WHERE tblAccountExec.pkid = " & accountid

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2006-02-14 : 19:10:49
You need to wrap it in single quotes. I.e. ... WHERE tblAccountExec.pkid = '" & accountid & "'".
It's not a great idea to construct your strings like this within your application. It's preferable in terms of security/maintainability/performance to encapsulate the functionality within a stored procedure and then call this from your application passing in parameter values as required. Also, I'd go with a more consistent naming convention to save on some serious headaches further down the line. Give your columns meaningful names and then make them consistent across tables. I.e. ... WHERE tab1.columnA = tab2.columnA.

Mark
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-02-14 : 20:06:43
Duplicate post http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61777

----------------------------------
'KH'

everything that has a beginning has an end
Go to Top of Page
   

- Advertisement -