M
mina
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
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