Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 692
Registered: ‎08-09-2010
My Device: Not Specified
Accepted Solution

When i fires select query but not get data so can you check?

Hello,

 

        When i fires this query no data get so can you help me it's ok?

 

        

DataSource {
                        id: durgSearch_dataSource
                        source: "sql/durg.db"
                        query: "select * from durg_detail where durg_name =" + "\"" + searchTextField.text + "\""
                        onDataLoaded: {
                            durgSearch_dataModel.insertList(data);
                        }
                    }

 

Developer
Developer
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook
My Carrier: MTS Ukraine

Re: When i fires select query but not get data so can you check?

try to use ' instead of "

 

                        query: "select * from durg_detail where durg_name = " + "'" + searchTextField.text + "'"

 

Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com
Developer
Posts: 692
Registered: ‎08-09-2010
My Device: Not Specified

Re: When i fires select query but not get data so can you check?

No get any result.

 

Please check below code.And also i attached full sourc code.So you get full idea about problem.I am waiting for your reply.

 

// Default empty project template
import bb.cascades 1.0
import bb.data 1.0
// creates one page with a label
Page {
    attachedObjects: [

        ImagePaintDefinition {
            id: titleBar_Bg
            repeatPattern: RepeatPattern.XY
            imageSource: "asset:///images/top_title_bg.png"
        },
        GroupDataModel {
            id: dataModel
            grouping: ItemGrouping.None
        },
        DataSource {
            id: dataSource
            source: "sql/FindMedicin.db"
            query: "select * from medicin_detail where PharmacyName = " + "'" + searchTextField.text + "'"
            onDataLoaded: {
                dataModel.insertList(data);
            }
        }
    ]
    //Please write a or r into search text field because only 4 data i add into database
    Container {

        Container {
            background: titleBar_Bg.imagePaint

            TextField {
                id: searchTextField
                objectName: "searchTextField"
                hintText: "Enter a Search Term"
                verticalAlignment: VerticalAlignment.Center
                preferredWidth: 560
                /* onTextChanged: {
                 * }*/
            }
            Button {
                id: searchBtn
                text: "Search"
                preferredHeight: 79
                preferredWidth: 159

                onClicked: {
                    dataSource.load();
                }
            }
            preferredHeight: 120
            preferredWidth: 768
            layout: StackLayout {
                orientation: LayoutOrientation.LeftToRight
            }
            leftPadding: 20.0
            rightPadding: 20.0
        }
        Container {
            ListView {
                dataModel: dataModel
                listItemComponents: [
                    ListItemComponent {
                        type: "item"
                        StandardListItem {
                            title: ListItemData.PharmacyName
                        }
                    }
                ]

            } // ListView
        }
    }
}

 

Developer
Developer
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook
My Carrier: MTS Ukraine

Re: When i fires select query but not get data so can you check?

You forgot to add

 

    onCreationCompleted:
    {
        dataSource.load();
    }

 to Page

Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com
Developer
Posts: 692
Registered: ‎08-09-2010
My Device: Not Specified

Re: When i fires select query but not get data so can you check?

I write code int to click event.

 

So can you check into Code.I put code into Click Event.

 

So when user enter a into searchtextfield at that time select query called and fetch the data.

Developer
Developer
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook
My Carrier: MTS Ukraine

Re: When i fires select query but not get data so can you check?

Ah, sorry. Didn't notice. Hm... Let me think.
Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com
Developer
Developer
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook
My Carrier: MTS Ukraine

Re: When i fires select query but not get data so can you check?

Look. I just tested your app and it works properly. I input Rock and push search button and it returns Rock record. If you would like to get all records which contain a particular letter or word you should use the following query:

 

"select * from medicin_detail where PharmacyName LIKE '%" + searchTextField.text + "%'"

 

Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com