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 2005 Forums
 Transact-SQL (2005)
 Query Syntax

Author  Topic 

melon.melon
Yak Posting Veteran

76 Posts

Posted - 2009-06-10 : 04:31:09
Incorrect syntax near '+'

string spName = "tb123";


cm = new SqlCommand("select *,u.CompanyName, a.VesselName, b.PortName from " + spName + " d,uvAllCompanyNames u," + "uvAllPort" + " a," + "uvAllVessel" + " b," + "where d.CompanyID=u.CompanyID and d.VesselName = a.VesselName and d.PortName = b.PortName", cn);

cm.Connection = cn;

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-10 : 04:33:17
"+" is the concatenating operator in .Net?
I know it is in T-SQL, but not long ago, "&" was the concatenating operator in VB.


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

melon.melon
Yak Posting Veteran

76 Posts

Posted - 2009-06-10 : 04:37:52
hi,

this is working:


select *,u.CompanyName, a.VesselName, b.PortName from " + spName + "
e, tbPorts a, tbVesselDetails b,
uvAllCompanyNames u, uvAllVessel c, uvAllPort d where d.CompanyID=u.CompanyID and d.VesselName = a.VesselName
Go to Top of Page

melon.melon
Yak Posting Veteran

76 Posts

Posted - 2009-06-10 : 05:34:28
hi solved.
Go to Top of Page
   

- Advertisement -