Monday, February 14, 2011

Re: [android-developers] Re: How to delete...?

Hi,

    My problem was solved like this..
myDB.execSQL("DELETE FROM favourites where month=' "+str1+" ' ");

On Tue, Feb 15, 2011 at 4:31 AM, JAlexoid (Aleksandr Panzin) <jalexoid@gmail.com> wrote:
Learn SQL first to deal with SQLite.

The problem with the code is that string values in SQL have to be
enclosed in single quotes.
DELETE FROM tablename where colname='SomeStringValue'

And change your code to proper code that does not have the SQL
injection problem:
myDB.execSQL("DELETE FROM tablename where colname= ? ",new Object[]
{string});

Read the following chapter: Using Databases
http://developer.android.com/intl/de/guide/topics/data/data-storage.html#db

At the end of it, there are 2 links to examples of complete
applications.

On 14 фев, 16:59, Abhilash baddam
> Hi,
>
>      what type of mistake is i am doing?
>
> On Mon, Feb 14, 2011 at 8:11 PM, Abhilash baddam <
>
> abhilash.androiddevelo...@gmail.com> wrote:
> > Hi,
>
> > In my code i used the command like this,*    *
> > *
> > *
> > * myDB.execSQL("DELETE FROM tablename where colname="+string,null);*
>
> >   In the place of args i am passing null, is it correct what exactly i have
> > to pass there.
>
> > On Mon, Feb 14, 2011 at 8:06 PM, Abhilash baddam <
> > abhilash.androiddevelo...@gmail.com> wrote:
>
> >> Hi,
>
> >>      i am getting that string, dynamically.
>
> >> On Mon, Feb 14, 2011 at 7:54 PM, Mark Murphy <mmur...@commonsware.com>wrote:
>
> >>> Use adb logcat, DDMS, or the DDMS perspective in Eclipse to examine
> >>> LogCat and look at your stack trace associated with your error.
>
> >>> In your case, you will find that you have invalid SQL, because your
> >>> string is not quoted. Please use:
>
> >>> String[] args={string};
> >>> myDB.execSQL("DELETE FROM tablename where colname=?", args);
>
> >>> On Mon, Feb 14, 2011 at 9:15 AM, Abhilash baddam
> >>> <abhilash.androiddevelo...@gmail.com> wrote:
> >>> > Hi,
> >>> >     In sqlite database, i am having some values. How can i delete a
> >>> > particular value from database. I tried like but showing error..
> >>> > What mistake is i am doin here..?
> >>> > myDB.execSQL("DELETE FROM tablename where colname="+string);
> >>> > i want to delete the value at that particulat string.
> >>> > Any help regarding this issue?
>
> >>> > --
> >>> > You received this message because you are subscribed to the Google
> >>> > Groups "Android Developers" group.
> >>> > To post to this group, send email to
> >>> android-developers@googlegroups.com
> >>> > To unsubscribe from this group, send email to
> >>> > android-developers+unsubscribe@googlegroups.com
> >>> > For more options, visit this group at
> >>> >http://groups.google.com/group/android-developers?hl=en
>
> >>> --
> >>> Mark Murphy (a Commons Guy)
> >>>http://commonsware.com|http://github.com/commonsguy
> >>>http://commonsware.com/blog|http://twitter.com/commonsguy
>
> >>> Warescription: Three Android Books, Plus Updates, One Low Price!
>
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "Android Developers" group.
> >>> To post to this group, send email to android-developers@googlegroups.com
> >>> To unsubscribe from this group, send email to
> >>> android-developers+unsubscribe@googlegroups.com
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment