Operation must use an updateable query. 
Author Message
 Operation must use an updateable query.

Dim Connection1 As OleDbConnection
Dim Command1 As OleDbCommand
Dim CommandBuilder1 As OleDbCommandBuilder
Dim DataAdapter1 As OleDBDataAdapater
Dim DataTable1 As DataTable
Dim DataRow1 As DataRow

define & open Connection1

Command1 = New OleDBCommand("select * from Table1",Connection1)
DataAdapter1 = New OleDBDataAdapter(Command1)
DataTable1 = New DataTable
DataAdapter1.Fill(DataTable1)
DataTable1.TableName = "Table1"
DataRow1 = DataTable1.NewRow()
DataRow("Field1") = "Value1"
DataTable1.Rows.Add(DataRow1)
OleDBDataAdapater.Update(DataTable)

error : "Operation must use an updateable query."



Thu, 30 Dec 2004 06:08:57 GMT  
 Operation must use an updateable query.
oops, that code should have been as follows :

(but it's the same idea)

trying to use OleDBDataAdapter.Update() method to insert rows into an MDB
table

Import System.Data.OleDb

Dim Connection1 As OleDbConnection
Dim Command1 As OleDbCommand
Dim CommandBuilder1 As OleDbCommandBuilder
Dim DataAdapter1 As OleDBDataAdapater
Dim DataTable1 As DataTable
Dim DataRow1 As DataRow

define & open Connection1

Command1 = New OleDBCommand("select * from Table1",Connection1)
DataAdapter1 = New OleDBDataAdapter(Command1)
CommandBuilder1 = New OleDbCommandBuilder(DataAdapter1)
DataAdapter1.DeleteCommand() = CommandBuilder1.GetDeleteCommand
DataAdapter1.InsertCommand() = CommandBuilder1.GetInsertCommand
DataAdapter1.UpdateCommand() = CommandBuilder1.GetUpdateCommand

DataTable1 = New DataTable
DataAdapter1.Fill(DataTable1)
DataTable1.TableName = "Table1"
DataRow1 = DataTable1.NewRow()
DataRow1("Field1") = "Value1"
DataTable1.Rows.Add(DataRow1)
OleDBDataAdapater.Update(DataTable1)

error : "Operation must use an updateable query."



Thu, 30 Dec 2004 10:14:13 GMT  
 Operation must use an updateable query.
It seems you haven't opened the connection and created the CommandBuilder.
Try this:

        Dim Connection1 As New
OleDbConnection("provider=microsoft.jet.oledb.4.0; data source=c:\db1.mdb")

        Dim Command1 As OleDbCommand
        Dim CommandBuilder1 As OleDbCommandBuilder
        Dim DataAdapter1 As OleDbDataAdapter
        Dim DataTable1 As DataTable
        Dim DataRow1 As DataRow

        Connection1.Open()

        Command1 = New OleDbCommand("select * from Table1", Connection1)
        DataAdapter1 = New OleDbDataAdapter(Command1)
        DataTable1 = New DataTable()
        DataAdapter1.Fill(DataTable1)
        DataTable1.TableName = "Table1"

        CommandBuilder1 = New OleDbCommandBuilder(DataAdapter1)

        DataRow1 = DataTable1.NewRow()
        DataRow1("id") = 20
        DataTable1.Rows.Add(DataRow1)
        DataAdapter1.Update(DataTable1)



Fri, 31 Dec 2004 16:32:02 GMT  
 Operation must use an updateable query.
Luke, In the original message I posted I forgot to include some code --
please see my response to myself.  Believe me, I am properly creating &
opening the connection, I am also properly creating the CommandBuilder and
using it to build the various commands for the DataAdapter.

If an MDB table includes an AutoNumber field, then perhaps it is necessary
to specify the value for that field ..... ?   One would expect AutoNumber to
... auto-number themselves ...



Quote:
> It seems you haven't opened the connection and created the CommandBuilder.
> Try this:

>         Dim Connection1 As New
> OleDbConnection("provider=microsoft.jet.oledb.4.0; data
source=c:\db1.mdb")

>         Dim Command1 As OleDbCommand
>         Dim CommandBuilder1 As OleDbCommandBuilder
>         Dim DataAdapter1 As OleDbDataAdapter
>         Dim DataTable1 As DataTable
>         Dim DataRow1 As DataRow

>         Connection1.Open()

>         Command1 = New OleDbCommand("select * from Table1", Connection1)
>         DataAdapter1 = New OleDbDataAdapter(Command1)
>         DataTable1 = New DataTable()
>         DataAdapter1.Fill(DataTable1)
>         DataTable1.TableName = "Table1"

>         CommandBuilder1 = New OleDbCommandBuilder(DataAdapter1)

>         DataRow1 = DataTable1.NewRow()
>         DataRow1("id") = 20
>         DataTable1.Rows.Add(DataRow1)
>         DataAdapter1.Update(DataTable1)



Sat, 01 Jan 2005 00:41:53 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Operation must use an updateable query. Error 3073

2. mdb/sql error: Operation must use an updateable query

3. 0x80004005 Operation must use an updateable query

4. Operation must use an updateable query.

5. Operation must use an updateable query (URGENT)

6. Operation Must be an updateable query?

7. HELP - Operation must use an updateable query

8. Operation must use an updateable query.

9. -2147467259 (80004005) Operation must be an updateable query

10. Operation must use an updateable query.

11. Operation must use an updateable query

12. Err: Operation Must use an Updateable Query.

 

 
Powered by phpBB® Forum Software