Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips > Official Updates
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Official Updates Updates to official libraries could be found here.
This forum is only available to licensed users.

SQL library was updated - V1.4

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-14-2008, 08:36 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default SQL library was updated - V1.4

The SQL library now supports parameterized queries.
Parameterized queries have several advantages over regular queries:
- Easy to use.
- No need to escape special characters.
- Protect against SQL injections.
- Significantly faster.

See Command.AddParameter and Command.SetParameter for more information.


Setup instructions:
Download and extract the attached file.
Copy all files to the libraries folder:
C:\Program Files\Anywhere Software\Basic4ppc Desktop\Libraries

Make sure to replace existing copies of SQLDesktop.dll and SQLDevice.dll with the new files.
Attached Files
File Type: zip SQL.zip (32.7 KB, 582 views)
Reply With Quote
  #2 (permalink)  
Old 06-14-2008, 12:20 PM
Filippo's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Schwäb. Gmünd, Germany
Posts: 906
Awards Showcase
Beta Tester 
Total Awards: 1
Default

very good

__________________
PPC: MDA Pro, 2GB SD
Device: HTC Desire , Android 2.2
______________________
Reply With Quote
  #3 (permalink)  
Old 06-14-2008, 06:18 PM
Knows the basics
 
Join Date: Jan 2008
Posts: 64
Default

Erel, it don't work on the device... Following code work on the desktop, but raises many errors on the device.
Code:
Sub Globals
    
'Declare the global variables here.

End Sub

Sub App_Start
    Con.New1
    Cmd.New1(
"",con.Value)
    Con.Open(
"Data Source = " & AppPath & "\Northwind.sl3")
    Text=
"CREATE TABLE if not exists table1 (col1,col2)"
    cmd.CommandText=Text
    cmd.ExecuteNonQuery
    
    cmd.AddParameter(
"value1")
    cmd.AddParameter(
"value2")
    cmd.CommandText = 
"INSERT INTO [table1] (col1,col2) VALUES (@value1,@value2)"
    Con.BeginTransaction
    cmd.SetParameter(
"value2","SomeValue")
    
For i = 0 To 10
        cmd.SetParameter(
"value1",i * 2)
        cmd.ExecuteNonQuery
    
Next
    Con.EndTransaction
    Con.Close
End Sub
Reply With Quote
  #4 (permalink)  
Old 06-14-2008, 06:39 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

It should work properly on the device.
Make sure you are using the updated library.
You can add:
Code:
Con.New1
Msgbox(Con.DLLVersion)
It should show 1.4.
Reply With Quote
  #5 (permalink)  
Old 06-14-2008, 06:58 PM
Knows the basics
 
Join Date: Jan 2008
Posts: 64
Default

hmm... yes, it shows "1.4" but still don't work... I've attached screenshot with the error. On the desktop, as i said, everything works fine...
Attached Images
File Type: jpg 1.jpg (26.4 KB, 79 views)
Reply With Quote
  #6 (permalink)  
Old 06-14-2008, 07:07 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

This error (which is not related to the new version) will only happen if you don't show any form.
You can fix it by explicitly disposing of the command and connection objects:
Code:
Sub App_Start
    Con.New1
    Cmd.New1(
"",con.Value)
    Con.Open(
"Data Source = " & AppPath & "\Northwind.sl3")
    Text=
"CREATE TABLE if not exists table1 (col1,col2)"
    cmd.CommandText=Text
    cmd.ExecuteNonQuery
    
    cmd.AddParameter(
"value1")
    cmd.AddParameter(
"value2")
    cmd.CommandText = 
"INSERT INTO [table1] (col1,col2) VALUES (@value1,@value2)"
    Con.BeginTransaction
    cmd.SetParameter(
"value2","SomeValue")
    
For i = 0 To 10
        cmd.SetParameter(
"value1",i * 2)
        cmd.ExecuteNonQuery
    
Next
    Con.EndTransaction
    Con.Close
<b>     cmd.Dispose
    Con.Dispose</b>
End Sub
Reply With Quote
  #7 (permalink)  
Old 06-14-2008, 07:16 PM
Knows the basics
 
Join Date: Jan 2008
Posts: 64
Default

wow... I didn't know about an error "when i don't show any form" , i've just started testing the new library. Yes, it works now, thanks Erel, and sorry for bothering...
Reply With Quote
  #8 (permalink)  
Old 08-18-2008, 01:43 AM
Junior Member
 
Join Date: Nov 2007
Posts: 24
Default

Is there anyway to use these parameter things with an UPDATE Sql command or do they only help with Inserts?

Edit: Got it! Turns out I'd got a comma in the wrong place which is why it didn't seem to be working! (Teach me to code when I should be in bed )

Anyway, for anyone else with such problems:
Code:
cmd.CommandText = "Update [Table] SET Col1 = @Value1, Col2 = @Value2 WHERE col3 = [whatever]"
works fine, just don't forget to watch the commas!

Last edited by Hennell : 08-18-2008 at 02:01 AM.
Reply With Quote
  #9 (permalink)  
Old 11-23-2009, 04:38 PM
Newbie
 
Join Date: Nov 2008
Posts: 8
Default

I had a project I started with SQL v1.3.
I updated the SQL files from the zip above in program files but I realized that it wasn't enough for my project.

I had to:
- remove all the objects related to SQL (connection, datareader, Command)
- remove the libraries (desktop and device) form the project
- assign again the SQL libraries (updated)
- recreate the objects

After that the projects was using SQL v1.4
Reply With Quote
  #10 (permalink)  
Old 11-23-2009, 08:28 PM
Newbie
 
Join Date: Nov 2008
Posts: 8
Default

I just realized that, instead of removing all the objects and recreate them with the new component, it is maybe sufficient to copy directly the dll to the folder where the project is stored and replace the existing ones.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
FormLib library was updated Erel Announcements 6 11-13-2009 09:38 PM
DesktopOnly library was updated Erel Announcements 0 12-24-2007 01:29 PM
Hardware library was updated - 3.00 Erel Announcements 1 09-10-2007 10:21 PM
Hardware library was updated Erel Announcements 17 05-31-2007 08:14 AM
FTP library was updated Erel Announcements 1 04-29-2007 04:04 PM


All times are GMT. The time now is 02:32 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0