----------------------------------------------------------- New Message on MumbaiUserGroup
----------------------------------------------------------- From: BusyWizy Message 2 in Discussion Hi Enclose table and column names with square brackets "[ ]". You could be having sql reserved words in your query Nauzad. > -----Original Message----- > From: arnab [mailto:[EMAIL PROTECTED] > Sent: Friday, July 23, 2004 6:34 PM > To: MumbaiUserGroup > Subject: Plz check this sql code > > ----------------------------------------------------------- > > New Message on MumbaiUserGroup > > ----------------------------------------------------------- > From: arnab > Message 1 in Discussion > > Hi, Got stuck in a problem. An sql query is giving the problem. My code is > as below: public DataSet gettables(string categoryID) > { > DataSet dataSet = new DataSet(); > string connectionString = "Provider=SQLOLEDB.1; Persist Security > Info=False; Initial Catalog=Spoof; Data Source=Localhost; User ID=sa; > Pwd=sa;"; // This code is not working // string sql ="SELECT > Tables.TableN AS TABLENAME,Tables.Stake AS STAKE,"; > // sql +="COUNT(CASE WHEN Status = 'P' THEN 'P' END) AS PLAYING,"; > // sql +="COUNT(CASE WHEN Status = 'W' THEN 'W' END) AS WATCHING"; > // sql +="FROM Tables Left Join Players ON Tables.TableN = > Players.TableNp"; > // sql +="WHERE CATEGORYID ='" + categoryID + "'"; > // sql +="GROUP BY TableN,Stake Order By Playing"; // This code is > working string sql = "SELECT Tables.TableN AS TableName,Tables.Stake AS > Stake FROM Tables where CategoryID = '" + categoryID + "'"; > OleDbConnection connection = new OleDbConnection( connectionString ); > OleDbDataAdapter adapter = new OleDbDataAdapter(); > adapter.SelectCommand = new OleDbCommand( sql , connection ); > adapter.Fill( dataSet ); > return dataSet; > } The query that is not working is :- string sql ="SELECT > Tables.TableN AS TABLENAME,Tables.Stake AS STAKE,"; > sql +="COUNT(CASE WHEN Status = 'P' THEN 'P' END) AS PLAYING,"; > sql +="COUNT(CASE WHEN Status = 'W' THEN 'W' END) AS WATCHING"; > sql +="FROM Tables Left Join Players ON Tables.TableN = > Players.TableNp"; > sql +="WHERE CATEGORYID ='" + categoryID + "'"; > sql +="GROUP BY TableN,Stake Order By Playing"; The exception that > I am getting is : "Line 1: Incorrect syntax near 'Tables'." The query > works perfectly in the sql server query analyzer. Any help will be > appreciated. Regards Arnab > > ----------------------------------------------------------- > > To stop getting this e-mail, or change how often it arrives, go to your E- > mail Settings. > http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw > > Need help? If you've forgotten your password, please go to Passport Member > Services. > http://groups.msn.com/_passportredir.msnw?ppmprop=help > > For other questions or feedback, go to our Contact Us page. > http://groups.msn.com/contact > > If you do not want to receive future e-mail from this MSN group, or if you > received this message by mistake, please click the "Remove" link below. On > the pre-addressed e-mail message that opens, simply click "Send". Your e- > mail address will be deleted from this group's mailing list. > mailto:[EMAIL PROTECTED] ----------------------------------------------------------- To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings. http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw Need help? If you've forgotten your password, please go to Passport Member Services. http://groups.msn.com/_passportredir.msnw?ppmprop=help For other questions or feedback, go to our Contact Us page. http://groups.msn.com/contact If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list. mailto:[EMAIL PROTECTED]
