![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | how to execute query which is use to truen result like pivot table I want to generate pivot table with the help of query view. SELECT * FROM accessTest PIVOT (Sum(Cash) FOR Ref IN (POS,BAC,BGC,EBP)) as PivotTable When i am tring to excute this query in my database it shows me correct out put. But when i am trying to execute same query through my vb.net code . it gives me "syntax error near From statement" This is my Code. sQuery = "SELECT * FROM accessTest " sQuery += " PIVOT (Sum(Cash) FOR Ref" sQuery += "IN(POS,BAC,BGC,EBP)) as PivotTable" Dim oCmd As OleDb.OleDbCommand Dim oConn As OleDb.OleDbConnection Dim oAdp As OleDb.OleDbDataAdapter oConn = New OleDbConnection(dbConn) oCmd = New OleDbCommand oCmd.Connection = oConn oCmd.CommandText = sQuery oCmd.CommandType = CommandType.TableDirect oAdp = New OleDbDataAdapter(oCmd) oAdp.Fill(ds, "TT") DataGridView1.DataSource = ds.Tables(0).DefaultView |
My System Specs![]() |
| | #2 (permalink) |
| | Re: how to execute query which is use to truen result like pivot table Looks like you're missing a leading space on the 3rd line in front of first word " IN(POS..." or at end of previous line.... Steve M "mina" <minakshi.patil@newsgroup> wrote in message news:b5cf1af9-93a9-4da1-9d80-37848862a400@newsgroup Quote: >I want to generate pivot table with the help of query view. > SELECT * FROM accessTest PIVOT (Sum(Cash) FOR Ref IN > (POS,BAC,BGC,EBP)) as PivotTable > When i am tring to excute this query in my database it shows me > correct out put. > > But when i am trying to execute same query through my vb.net code . it > gives me "syntax error near From statement" > This is my Code. > > > sQuery = "SELECT * FROM accessTest " > sQuery += " PIVOT (Sum(Cash) FOR Ref" > sQuery += "IN(POS,BAC,BGC,EBP)) as PivotTable" > Dim oCmd As OleDb.OleDbCommand > Dim oConn As OleDb.OleDbConnection > Dim oAdp As OleDb.OleDbDataAdapter > oConn = New OleDbConnection(dbConn) > oCmd = New OleDbCommand > oCmd.Connection = oConn > oCmd.CommandText = sQuery > oCmd.CommandType = CommandType.TableDirect > oAdp = New OleDbDataAdapter(oCmd) > oAdp.Fill(ds, "TT") > DataGridView1.DataSource = ds.Tables(0).DefaultView |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| WMI query results not giving the expected result | PowerShell | |||
| execute mysql query using vbscript | VB Script | |||
| how do you create a dynamic table/pivot table | .NET General | |||
| execute Exchange script from DOS - how to get result? | PowerShell | |||
| Can't execute T-SQL query | PowerShell | |||