Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


What is about SQLite Methods like AExecute, LastError or Interrupt...


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-04-2008, 12:45 PM
Knows the basics
 
Join Date: Dec 2007
Posts: 69
Awards Showcase
Beta Tester 
Total Awards: 1
Default What is about SQLite Methods like AExecute, LastError or Interrupt...

Hello together,
does anybody know how to use SQLite Methods from the SQlite Object Reference in B4P??
Especially the AExcute method is very helpfull to do insertions. No Apostrophs, Chr(34) .... -constucts are needed, you put your Values into an array and insert it to the table.
In NSBasic it is used in this way:
arr(0) = UrAktTab 'IDStr
arr(1) = NewFi 'TNam
arr(2) = UrSpAnz 'HGroesse
arr(3) = FiAusdruck 'HVeraendert
arr(4) = CStr(SpAnz)
arr(5) = CNa
arr(6) = ColW
sqlins = "INSERT INTO [SysDBObs] VALUES (?,?,?,?,?,?)"
db.Execute ("BEGIN TRANSACTION")
db.AExecute sqlins, arr
db.Execute ("COMMIT TRANSACTION")
If db.lastError <> "" Then
MsgBox "Error occured: " & db.lastError
db.lastError = ""
End If
LastError is also usefull, but I don't know how to use.

Best regards

berndgoedecke
Reply With Quote
  #2 (permalink)  
Old 05-04-2008, 01:14 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,334
Default

Support for parameterized queries will be added in the next update of the SQL library.
The syntax will not be exactly as you described but it will make it easier to build complex queries.

When an error occurs, the error is "thrown" and if not caught by an ErrorLabel the error message will be shown.
Reply With Quote
  #3 (permalink)  
Old 06-09-2008, 07:29 PM
Knows the basics
 
Join Date: Dec 2007
Posts: 69
Awards Showcase
Beta Tester 
Total Awards: 1
Default Is the Sqlite-Update forthcoming?

Hello Erel,
it's a late reply, but now, actual I have a problem with Datasets that have " and ', so it would be very helpful to have the AExecute -function to avoid complications with the SQL-special keys.
If the Update is not forthcoming it makes sense to create a workaround.

Best regards

berndgoedecke
Reply With Quote
  #4 (permalink)  
Old 06-14-2008, 08:39 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,334
Default

The SQL library now supports (named) parameterized queries: SQL library was updated - V1.4
Reply With Quote
  #5 (permalink)  
Old 07-03-2008, 06:17 PM
Knows the basics
 
Join Date: Dec 2007
Posts: 69
Awards Showcase
Beta Tester 
Total Awards: 1
Default Thank you for the parameter methods

Hello Erel,
in the meantime I've tested the new Parameter methods in the Sql.dll. It works fine with Text and Varchar, but what is about Real and Integer. Curretly I try to get a table with all Sqlite3 Storage classes(NULL,INTEGER,REAL,TEXT,BLOB). I've tried different Methods to convert a formated String (eg.:1,154,125.456897) but REAL could not be inserted in the table as REAL.
One suspicion for the incompatibility is that Value in SetParameter is a String,
another is the SQLite-Version 3.3.1.2 you are using for the Sql.dll.
On Sqlite.org I've seen that later Version get a Bug-Fixed for handling Real numbers.
On the way, is it possible rename the native SQLite-Library in System.Data.SQLite.DLL to get a new SQLite Version?

I'm thankful for every hint.

Best regards
berndgoedecke
Reply With Quote
  #6 (permalink)  
Old 07-03-2008, 07:14 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,334
Default

I don't see any problem with REAL values.
See this code for example:
Code:
Sub Globals

End Sub

Sub App_Start
    con.New1
    cmd.New1("",con.Value)
    Con.Open("Data Source = " & AppPath & "\1.db")
    CreateTable
    cmd.AddParameter("value1")
    cmd.CommandText = "INSERT INTO table1 (col1) VALUES (@value1)"
    For i = 1 To 2 Step 0.33
        cmd.SetParameter("value1",i)
        cmd.ExecuteNonQuery
    Next
End Sub
Sub CreateTable
    cmd.CommandText = "CREATE TABLE IF NOT EXISTS table1 (col1 REAL)"
    cmd.ExecuteNonQuery
End Sub
Basic4ppc uses a modified version of System.Data.SQLite.dll and therefore it is not possible to simply replace the file.
Reply With Quote
  #7 (permalink)  
Old 07-08-2008, 06:03 PM
Knows the basics
 
Join Date: Dec 2007
Posts: 69
Awards Showcase
Beta Tester 
Total Awards: 1
Default Some feedback

Hello Erel,
thanks for your reply. The error was that SQLite don't understand a formated String like eg.:1,154,125.456897. It must be 1154125.456897.
StrReplace or Regex.Replace(because it's implemented anyway) is the choice to
get the right formatting.

Best regards

berndgoedecke
Reply With Quote
  #8 (permalink)  
Old 07-15-2008, 06:31 PM
Knows the basics
 
Join Date: Dec 2007
Posts: 69
Awards Showcase
Beta Tester 
Total Awards: 1
Default OleDateTime functions ?

Hello Erel,
just in time I have a problem with the skin of Date-values in SQLite. SQLites-OleDateTime functions may be not compatible with the B4P Date Format , but they can be useful to be more compatible to MS applications like Outlook etc.(see also Problems with outlook.dll)
Is there a way to use this functions with the avaliable command set, or is another Update needed ??

best regards

berndgoedecke
Reply With Quote
  #9 (permalink)  
Old 07-15-2008, 06:52 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,334
Default

What problems do you encounter with the date format?
Reply With Quote
  #10 (permalink)  
Old 07-15-2008, 07:52 PM
Knows the basics
 
Join Date: Dec 2007
Posts: 69
Awards Showcase
Beta Tester 
Total Awards: 1
Default Problems with date format

If I use the SQLite3 Session parameter function RefDate() the result is a Real Number as it is shown in the attached RefDate.jpg. So it is proved that the OLE-DateFormat (startdate: 12/30/1899) is used by SQLite3. Real numbers are also used by the useful OLEDateDiff(X,Y,Z) function. SQLite is not able sort real numbers, but you can use Sorted By abs(Date) to get a numeric sort order instead of an alphabeticly.(For sorting, an integer Date should be better)
SQLite3-OleDate functions are interpreting the Real number as a formated string as it is shown in OleDateTime.jpg

To get the "real"-date from a String I'wrote this:
(The whole Source is here:Listview.dll)
Dim Dop(0) As Double
'
'
'
x = "30.12.1899" '0 Date correction
DNp = DateParse(x)
x = "01.01.4501" 'max= 949998
DMp = DateParse(x)
DKorr= 949998 /(DMp-DNp)
'
'
'
Dop(0) = (DateParse (TempArr(j)) -DNp)* DKorr
cmd.SetParameter(ParmName(j),Dop(0))

The problem i now have, is how to use the the functions that are avaliable in SQLite.

best regards

berndgoedecke
Attached Images
File Type: jpg RefDate.jpg (56.3 KB, 11 views)
File Type: jpg OleDateTime.jpg (55.8 KB, 11 views)
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Proper use of the .New methods, out of memory error kolbe Questions & Help Needed 5 09-05-2008 02:37 PM
DateTime compatibility methods berndgoedecke Basic4ppc Wishlist 4 08-31-2008 06:43 PM
Http Methods, waht do they do?? Cableguy Questions & Help Needed 6 07-27-2008 04:56 PM


All times are GMT. The time now is 02:05 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0