B
Barbara Pickerd
I’m a beginner.
I want to add a new record to my table; however I get an error:
“An unhandled exception of type 'System.InvalidOperationException'
occurred in system.data.dll
Additional information: Dynamic SQL generation is not supported against
a SelectCommand that does not return any base table information.”
Here is my code:
Private m_cnADONetConnection As New OleDb.OleDbConnection
Private m_daDataAdapter As New OleDb.OleDbDataAdapter
Private m_cbCommandBuilder As OleDb.OleDbCommandBuilder
'Private m_Insert As OleDb.OleDb.OleDbInsertCommand1
Private m_dtContacts As New DataTable
'Private m_dtContacts As New DataTable
Private m_rowPosition As Integer = 0
Private Sub btnAddNew_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) _
Handles btnAddNew.Click
Dim drNewRow As DataRow = m_dtContacts.NewRow
drNewRow("Number") = TxtAddNumber.Text
drNewRow("First") = txtAddFirst.Text
drNewRow("Last") = txtAddLast.Text
drNewRow("Status") = TxtAddStatus.Text
m_dtContacts.Rows.Add(drNewRow)
m_daDataAdapter.Update(m_dtContacts)
m_rowPosition = m_dtContacts.Rows.Count - 1
Me.ShowCurrentRecord()
End Sub
I want to add a new record to my table; however I get an error:
“An unhandled exception of type 'System.InvalidOperationException'
occurred in system.data.dll
Additional information: Dynamic SQL generation is not supported against
a SelectCommand that does not return any base table information.”
Here is my code:
Private m_cnADONetConnection As New OleDb.OleDbConnection
Private m_daDataAdapter As New OleDb.OleDbDataAdapter
Private m_cbCommandBuilder As OleDb.OleDbCommandBuilder
'Private m_Insert As OleDb.OleDb.OleDbInsertCommand1
Private m_dtContacts As New DataTable
'Private m_dtContacts As New DataTable
Private m_rowPosition As Integer = 0
Private Sub btnAddNew_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) _
Handles btnAddNew.Click
Dim drNewRow As DataRow = m_dtContacts.NewRow
drNewRow("Number") = TxtAddNumber.Text
drNewRow("First") = txtAddFirst.Text
drNewRow("Last") = txtAddLast.Text
drNewRow("Status") = TxtAddStatus.Text
m_dtContacts.Rows.Add(drNewRow)
m_daDataAdapter.Update(m_dtContacts)
m_rowPosition = m_dtContacts.Rows.Count - 1
Me.ShowCurrentRecord()
End Sub