IonicWind Software

IWBasic => General Questions => Topic started by: aronoffs on April 23, 2008, 11:00:02 AM

Title: Can't update or delete.
Post by: aronoffs on April 23, 2008, 11:00:02 AM
I created my first database ("Microsoft Access Driver (*.mdb)") and am able to successfully select from and insert rows into a table.  However, I cannot delete or update rows in that table.  I get a null return code  from the dbExecSql statement and nothing changes in the table.

Here is an example of a Delete I tried:

sqlstmt = "DELETE FROM QuestTbl WHERE RowNum = 0"   /* RowNum is a field in the table */
ptr = DBEXECSQL(dbPtr,sqlstmt)      /* ptr and dbPtr are pointers. */
error = dbGetErrorCode(ptr)
IF LEN(error)
   MESSAGEBOX w, dbGetErrorText(ptr), "Delete of row zero failed"
   dbFreeSql(ptr)
   END
ENDIF
dbFreeSql(ptr)

Is there something I'm doing wrong?
In the help file it mentions using SqlGetInfo to find out info about my database but I can't figure out how to use it.  Is that worth looking into, and if so, what does a SQLGETINFO command look like?

Thanks.
Title: Re: Can't update or delete.
Post by: Ionic Wind Support Team on April 23, 2008, 11:25:43 AM
Your SQL statement has nothing to delete in it.

DELETE item FROM table WHERE condition

Title: Re: Can't update or delete.
Post by: aronoffs on April 23, 2008, 03:04:19 PM
The Delete statement is trying to remove the row whose RowNum value is 0.
Title: Re: Can't update or delete.
Post by: Rock Ridge Farm (Larry) on April 23, 2008, 03:18:12 PM
I have found that it works better if you select the item before you delete it.
Title: Re: Can't update or delete.
Post by: aronoffs on April 23, 2008, 03:26:42 PM
Larry,

You're saying do a Select of the row, then follow this immediately with the Delete or Update?  I can do that if that's what it takes.  Is this a glitch with the MS Access Driver and EBasic? 

Would I be better off using something like SQLITE?

Title: Re: Can't update or delete.
Post by: LarryMc on April 23, 2008, 03:27:53 PM
What type of field is RowNum in the database?

The other Larry
Title: Re: Can't update or delete.
Post by: aronoffs on April 23, 2008, 05:31:38 PM
It's an Integer type.
Title: Re: Can't update or delete.
Post by: LarryMc on April 23, 2008, 06:03:20 PM
Is there actually a record with a 0 in the RowNum field?

Larry
Title: Re: Can't update or delete.
Post by: LarryMc on April 23, 2008, 06:16:11 PM
Only thing I can suggest is post your code and the dbase file so I or someone else can run it and see what's going on.

Larry
Title: Re: Can't update or delete.
Post by: aronoffs on April 24, 2008, 09:51:40 AM
Well it turns out there was a logic problem in my program.  When fixed, all worked well.

Sorry for the trouble.

One other question: 
My database was of type Microsoft Access Driver (*.mdb).  Is there a more robust free database besides this that will work with Vista?

Stu
Title: Re: Can't update or delete.
Post by: Locodarwin on April 24, 2008, 10:47:53 AM
MySQL:

http://www.mysql.com/

Basically the most popular.  It's industry standard anymore.  Microsoft also supplies an excellent version of it for free called "Microsoft SQL Server Express."

-S
Title: Re: Can't update or delete.
Post by: Locodarwin on April 24, 2008, 10:56:26 AM
By the way, Sun likes to hide the free version of MySQL (Community Server) as they're always trying to push their paid version.  You can find Community Server 5.1 (latest stable/tested release) here:

http://dev.mysql.com/downloads/mysql/5.1.html

-S
Title: Re: Can't update or delete.
Post by: aronoffs on April 24, 2008, 11:18:43 AM
Thanks.  I'll check it out.