About SQL Database

Discussion in 'Questions (Windows Mobile)' started by gjoisa, Feb 17, 2008.

  1. gjoisa

    gjoisa Active Member Licensed User

    Hi
    I have created a database called "Atlas.sl3" with SQL . My question is, how to get the first field of a record with key ? My intention is to get the first fields of all records in a list , when i type 1 or 2 letters in a textbox and clicking a button . eg: when i type 'A' ,all first fields of records (Agra , Ajmer , Ahmedabad) starting with "A" should be added to a listbox . how to write the coding ?
     
  2. willisgt

    willisgt Active Member Licensed User

    On each key press (I presume the user is typing into a text box), create and execute a new sql query, like such:

    "SELECT field1,field2,field3 FROM (your_table_name) WHERE field1 LIKE '" & textbox1.text & "%' "

    Be warned, this method can be slow, especially if you've got a lot of data. You might consider reading the contents of the database into a table, and extracting only the records matching your search - especially if the data won't be modified by the user.

    Gary
     
    Last edited: Feb 17, 2008
  3. gjoisa

    gjoisa Active Member Licensed User

    thank you for your suggession . now i have problem in compiling after setting database actions .there comes one error message about SQL . pls help me .
     
    Last edited: Feb 17, 2008
  4. Erel

    Erel Administrator Staff Member Licensed User

    Can you describe the error message or take a screen shot of it?
     
  5. gjoisa

    gjoisa Active Member Licensed User

    the error message reads so ;"Error Compiling Program . Error message : Error CS0012 : The type 'System.Data.Common.DBConnection' is defined in an assembly 'System.Data,Version=2.0.0.0, Culture=neutral,PublicKeyToken=b77a5c561934e089'.Line Number=25 . Line:Com.New1("""",con.Value)" .

    I have added System.data.SQLite.dll in both desktop and device(seperately as required) in components . I used here 'com' for command . I think this much can help you to understand my problem .
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    You shouldn't add System.data.SQLite.dll in the components dialog.
     
  7. gjoisa

    gjoisa Active Member Licensed User

    then which sql dll files to be added ?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    You should add SQLDesktop to the desktop and SQLDevice to the device.
    Later when you distribute your application you should include System.Data.SQLite.dll (from Libraries\SQLNative folder).
     
  9. gjoisa

    gjoisa Active Member Licensed User

    i have added the dll files as directed by you . After when tried to compile there is another error message :Error CS00234: The type or namespacename 'SQLite' does not exist in the namespace 'System.data" .(Are you missisng an assembly reference?) .what does it mean ? what to do ?:sign0085:
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    You are probably not using the updated SQLDesktop / SQLDevice.
    Please download the attached files and copy them to your source code folder.
    SQLDesktop and SQLDevice date should be 11/25/2007.
     

    Attached Files:

  11. gjoisa

    gjoisa Active Member Licensed User

    I have added the dll files just sent by you . still there is error message .Error CS0246: The type or namespace name 'SQL' couldnot be found .(Are you missing a using directive or an assembly reference ?)
     
    Last edited: Feb 17, 2008
  12. Erel

    Erel Administrator Staff Member Licensed User

    Can you zip your complete project (including libraries) and send it to me: erel@basic4ppc.com ?
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    As I wrote you in a previous post, you should replace SQLDesktop.dll with the updated file.
    Currently you are using SQLDesktop.dll from 3/14/2007.
    You should replace it with the one from 11/25/2007.
    You could download it in post #10 of this thread.
    Afterwards your application compiles fine.

    Don't forget that you should also distribute System.Data.SQLite.dll which is located under:
    C:\Program Files\Anywhere Software\Basic4ppc Desktop\Libraries\SQLNative
     
Loading...