Update Command not working!

Results 1 to 2 of 2

Thread: Update Command not working!

  1. #1
    Join Date
    Dec 1969

    Default Update Command not working!

    Hi everyone, I am using this simple code to test how it works, but I get this error, Could you please tell me which part of code is wrong? I am copying from a book. Thanks in advance.<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 StudioVB98Nwind2000.mdb"<BR> dim Conn as new OLEDBConnection(ConnStr)<BR> dim strSQL as string="select * from employees where EmployeeID &#060; 10"<BR> dim objCmd as new OLEDBDataAdapter(strSQL,Conn) <BR> <BR> objCmd.fill(ds,"Employees") <BR> dim dr as datarow=ds.Tables("Employees").NewRow()<BR> dr(0)=1000<BR> dr(1)="SS"<BR> dr(2)="DD"<BR> ds.Tables("Employees").Rows.add(dr)<BR> <BR> objCmd.UpdateCommand=new oledbcommand<BR> objCmd.UpdateCommand.CommandText="update Employees set FirstName=&#039;Nancy1&#039; where firstname=&#039;Nancy&#039;"<BR> objcmd.UpdateCommand.Connection=Conn<BR> objcmd.update(ds,"Employees")<BR> <BR> end sub<BR><BR>Error: Operation must use an updateable query.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Update Command not working!

    You probably need to explicitly open and close the connection before calling the Update() method. I.e.: <BR><BR>conn.Open()<BR>adapter.Update(...)<BR>conn .Close()

Posting Permissions

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