Dynamic SQL generation is not supported against a SelectCommand ...

  • Thread starter Thread starter Irfan
  • Start date Start date
I

Irfan

hi,
I am getting the following error.
Dynamic SQL generation is not supported against a SelectCommand that does
not return any base table information

when i try to use da.update

I squeezed my program to just few lines to know the reason for this error.
Atlast,
i found that if i am using the stored procedures to get the data, then this
error is caused, If i simply use

Dim cmd As New OleDbCommand("select * from table1", con)
it does not give any error.

But i need to use stored procedures in my program , could someone please
tell if their is any work around

Here is the few lines of code

Dim con As New OleDbConnection(ConnString)
da = New OleDbDataAdapter

ds = New DataSet()

Dim cmd As New OleDbCommand("select * from table1", con)

' Dim cmd As New OleDbCommand("q1", con)

' cmd.CommandType = CommandType.StoredProcedure

da.SelectCommand = cmd

da.FillSchema(ds, SchemaType.Source, "myTable")

da.Fill(ds, "mytable")

Dim cmdbuider As New OleDbCommandBuilder(da)

DataGridView1.DataSource = ds

DataGridView1.DataMember = "mytable"
 
Irfan,

In my opinion does this not need a workaround, this sounds if your stored
procedure is wrong.

Is that as simple as you show now.
Otherwise try it first in the way you did now, however not as stored
procedure but as now with commandtext.

I hope this helps,

Cor
 
Back
Top