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.

Update\Insert In SQLLite

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-02-2008, 11:19 AM
ceaser's Avatar
Basic4ppc Veteran
 
Join Date: May 2008
Location: Paarl, South Africa
Posts: 312
Default Update\Insert In SQLLite

Help Please

When entering coordinates via the keyboard (not imported), I have one button that says "Save". How do I go about letting the program know that it is a new point entered and not an updated one. I thought of doing first an "Update" and if that fails then do an "Insert".

What happens if I first try an "Update", what returns if this "Update" fails, so that the program knows that it is a new point entered??

Thanks
Michael
Reply With Quote
  #2 (permalink)  
Old 10-02-2008, 02:58 PM
ceaser's Avatar
Basic4ppc Veteran
 
Join Date: May 2008
Location: Paarl, South Africa
Posts: 312
Default

OK I have figured it out:

ErrorLabel (DupPoints)
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=0 Then Goto DupPoints
Return
Else
Msgbox ("Enter A Valid Point Name", "Point Name", cMsgboxOK, cMsgboxExclamation)
PntName.Focus
Return
End If

DupPoints:
'The name does not exist so add the new data
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


A will be "1" be the point exists in which case I update the data, else if A is "0" then the point does not exists and I insert a new field.

Thanks
Michael
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
How to insert the generated text into code ? mozaharul Questions (Windows Mobile) 3 10-06-2008 06:42 AM
ControlsEx update Erel Official Updates 0 03-14-2008 05:11 PM
Serial2 update - V1.2 Erel Official Updates 0 01-18-2008 08:26 AM
Update about Basic4ppc V6.0 Erel Announcements 5 12-15-2007 05:37 AM
Update on the next version Erel Announcements 25 09-14-2007 01:12 PM


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


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