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.

SQL Questions

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-24-2007, 10:31 AM
Knows the basics
 
Join Date: May 2007
Posts: 93
Default SQL Questions

Hi Erel,

I am trying out this this SQL expression

SUB btnExecute_click
cmd.CommandText=" SELECT DISTINCT NAME, RANK, CODE FROM CUSTS ORDER BY NAME"
cmd.ExecuteTable("table1",0)
cmd.CommandText=" SELECT DISTINCT DUTY, DATE1, TIME, FLTNO, DATE2 FROM CUSTS WHERE NAME='JOHN' ORDER BY DATE1"
cmd.ExecuteTable("table2",0)
end sub

From the WHERE NAME='JOHN', how could I replace 'JOHN' form a textbox.text?

Thanks
TC
Reply With Quote
  #2 (permalink)  
Old 12-24-2007, 10:57 AM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 173
Default

Dear TC,

Have a look at the demo-program by Giannimaione (thread http://www.basic4ppc.com/forum/showt...hlight=demosql)

It is a very short program but it contains many useful hints, amongst them the answer to your question.

all the best,

Björn

*****************************

quote=CHR(39)

Sub Button1_Click
'insert data
MyData1=quote & "ALFA" & quote
'or MyData1=quote & textbox.Text & quote
MyData2=Quote & "BETA" & quote

text="insert into NameTable (Field1, Field2) values ("
text=text & MyData1 & "," & MyData2 & ")"
Msgbox(text)
cmd.CommandText=text
cmd.ExecuteNonQuery
End Sub
Reply With Quote
  #3 (permalink)  
Old 12-24-2007, 10:58 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,732
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Try:
Code:
    cmd.CommandText="... WHERE NAME = '" & textbox.text & "' ORDER ..."
Reply With Quote
  #4 (permalink)  
Old 12-26-2007, 03:00 AM
Knows the basics
 
Join Date: May 2007
Posts: 93
Default

Got it!

Thanks Erel.
Reply With Quote
  #5 (permalink)  
Old 12-29-2007, 12:18 PM
Knows the basics
 
Join Date: May 2007
Posts: 93
Default

Hi AnyOne with SQL knowledge,

1st of all thanks for all the help, now I'm learning to program SQL slowly.

I have a problem now with WHERE statement:

If WHERE = ' name with a' in between' How do I go around with this ' problem?

Thanks
Reply With Quote
  #6 (permalink)  
Old 12-29-2007, 12:40 PM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Ioannina, Greece
Posts: 356
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Add one more ' beside the one that exists
__________________
Dimitris Zacharakis
http://www.terracom.gr
Reply With Quote
  #7 (permalink)  
Old 12-31-2007, 08:51 AM
Knows the basics
 
Join Date: May 2007
Posts: 93
Default

Thanks! But what if the database comes with names which have ' ?

How do I filter out these names?

Thanks n Happy New year.
Reply With Quote
  #8 (permalink)  
Old 12-31-2007, 09:10 AM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Ioannina, Greece
Posts: 356
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

You should search for it and replace it

StrReplace
("name", "'", "''")
__________________
Dimitris Zacharakis
http://www.terracom.gr
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
A few questions regarding FormLib N1c0_ds Questions (Windows Mobile) 6 09-19-2008 02:34 AM
Newbie Questions Bruno Questions (Windows Mobile) 2 05-05-2008 06:45 PM
Questions on SpecialKeys HARRY Questions (Windows Mobile) 5 02-26-2008 01:55 PM
One of my stupid questions.... Cableguy Questions (Windows Mobile) 7 01-27-2008 10:26 AM
More SQL questions HARRY Questions (Windows Mobile) 2 01-04-2008 10:15 AM


All times are GMT. The time now is 06:18 AM.


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