The code below throws the following error:
System.InvalidOperationException: Dynamic SQL generation failed. No key
information found
at Oracle.DataAccess.Client.OracleCommandBuilder.CheckPrimaryKey()
at Oracle.DataAccess.Client.OracleCommandBuilder.GetUpdateCommand()
----------
Dim cnOracle As Oracle.DataAccess.Client.OracleConnection
Dim daOracle As Oracle.DataAccess.Client.OracleDataAdapter
Dim oCmd As Oracle.DataAccess.Client.OracleCommand
Dim ocb As Oracle.DataAccess.Client.OracleCommandBuilder
Dim sql As String
Dim dt As DataTable
Dim dr As DataRow
' Open DB
cnOracle = New Oracle.DataAccess.Client.OracleConnection( _
"Data Source=" & TextBox1.Text & ";User Id=" & TextBox2.Text &
";Password=" & TextBox3.Text & ";")
daOracle = New Oracle.DataAccess.Client.OracleDataAdapter
cnOracle.Open()
' Drop table
sql = "drop table mytable"
oCmd = New Oracle.DataAccess.Client.OracleCommand(sql, cnOracle)
Try
oCmd.ExecuteNonQuery()
Catch ex As Oracle.DataAccess.Client.OracleException
End Try
' Create table without any primary key
sql = "create table mytable ( id number(10), value varchar2(20) )"
oCmd = New Oracle.DataAccess.Client.OracleCommand(sql, cnOracle)
oCmd.ExecuteNonQuery()
' Load empty table from db
dt = New DataTable
sql = "select * from mytable"
daOracle.SelectCommand = New Oracle.DataAccess.Client.OracleCommand(sql,
cnOracle)
daOracle.Fill(dt)
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.