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

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

SQLLite

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-12-2008, 06:07 PM
ceaser's Avatar
Basic4ppc Veteran
 
Join Date: May 2008
Location: Paarl, South Africa
Posts: 312
Unhappy SQLLite

Hi All

I get to grips with B4PPC - with everything, except SQLLte I have the following code where I can store a coordinate or update a coordinate:

Sub SaveCoord_Click
Dim a

ErrorLabel (NoPoint)
If PntName.Text<>"" Then
If CFile=0 Then
text="update LCoords Set YCoord = '"
Else If CFile=1 Then
text="update LCoords Set YCoord = '"
Else
text="update LCoords Set YCoord = '"
End If
Text=Text & YCoord.Text & "'," & "XCoord = '" & XCoord.Text & "'," & "ZCoord = '" & ZCoord.Text
Text=Text & "'," & "Description = '" & Descrip.Text & "'"
Text=Text & " where PntName = '" & PntName.Text &"'"
cmd.CommandText=text
A=cmd.ExecuteNonQuery
*** If A=1 Then
'Point exits
Msgbox ("Point Exists - Override?", "Point Exits", cMsgboxYesNo, cMsgboxQuestion)
End If **
If A=0 Then Goto NoPoint
ShowCoords(1,CFile)
Return
Else
Msgbox ("Enter A Valid Point Name", "Point Name", cMsgboxOK, cMsgboxExclamation)
PntName.Focus
Return
End If

NoPoint:
'The point does not exist so add the new point
If CFile=0 Then
text="insert into LCoords (PntName,YCoord,XCoord,ZCoord,Description) values ('"
Else If CFile=1 Then
text="insert into GCoords (PntName,YCoord,XCoord,ZCoord,Description) values ('"
Else
text="insert into SCoords (PntName,YCoord,XCoord,ZCoord,Description) values ('"
End If
text=text & PntName.Text & "','" & YCoord.Text & "','" & XCoord.Text & "','" & ZCoord.Text & "','" & Descrip.Text & "')"
cmd.CommandText=text
cmd.ExecuteNonQuery
ShowCoords(1,CFile)
End Sub

Looking at the line codes marked with an astrixs, is where when A=1, the point exists and the new values get updated. How can I "Rollback" that command or have another command to check if the point exists before the values get changed in the database?

Thanks
Michael
Reply With Quote
  #2 (permalink)  
Old 10-12-2008, 07:26 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

I really recommend you to try to use parameterized queries.
Your code will be much simpler.

Can't you first run a SELECT query and only then run the UPDATE query if needed?
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
Problema SQLlite manu Spanish Forum 2 08-22-2011 11:46 AM
Update\Insert In SQLLite ceaser Questions (Windows Mobile) 1 10-02-2008 02:58 PM
Delete from SQLlite ceaser Questions (Windows Mobile) 2 08-24-2008 07:29 AM
Me And SQLLite Again ceaser Questions (Windows Mobile) 3 08-12-2008 04:36 AM
how to connect SQLlite on pocketpc thaidelphi Questions (Windows Mobile) 1 08-05-2008 05:01 AM


All times are GMT. The time now is 07:45 AM.


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