Simple ADO.NET Update Command not working!

Results 1 to 2 of 2

Thread: Simple ADO.NET Update Command not working!

  1. #1
    Join Date
    Dec 1969

    Default Simple ADO.NET Update Command not working!

    Hi,<BR>This simple piece of code that I copied from a book, gives me this error: "Operation must use an updateable query. "<BR>Could someone please tell me what I am doing wrong?<BR><BR> sub Page_load(obj as object, e as Eventargs)<BR> dim ConnStr as string="Provider=Microsoft.jet.oledb.4.0; data source=C:Program FilesMicrosoft Visual StudioVB98BiblIO2000.mdb"<BR> dim Conn as new OLEDBConnection(ConnStr)<BR> dim strSQL as string="select * from authors where au_ID &#060; 10"<BR> dim objCmd as new OLEDBDataAdapter(strSQL,Conn) <BR> dim ds as new Dataset("MyDataSet")<BR><BR> objCmd.fill(ds,"Authors") <BR> dim dr as datarow=ds.Tables("Authors").NewRow()<BR> dr(0)=1000<BR> dr(1)="Sh"<BR> dr(2)=1991<BR> ds.Tables("Authors").Rows.add(dr)<BR> <BR> objCmd.UpdateCommand=new oledbcommand<BR> objCmd.UpdateCommand.CommandText="update Authors set YearBorn=1991 where au_ID=4"<BR> objcmd.UpdateCommand.Connection=Conn<BR> <BR> objCmd.InsertCommand=New oledbCommand<BR> objcmd.InsertCommand.CommandText="insert into Authors (au_id,Author,YearBorn) values (1000,&#039;SH&#039;,1991)"<BR> objCmd.InsertCommand.Connection=Conn<BR> objcmd.update(ds,"Authors")<BR> Conn.close<BR> end sub<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Simple ADO.NET Update Command not working!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts