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.


SQL Questions


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-24-2007, 11:31 AM
Junior Member
 
Join Date: May 2007
Posts: 29
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, 11:57 AM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 143
Default

Dear TC,

Have a look at the demo-program by Giannimaione (thread Sample sqllite application)

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, 11:58 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,334
Default

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

Got it!

Thanks Erel.
Reply With Quote
  #5 (permalink)  
Old 12-29-2007, 01:18 PM
Junior Member
 
Join Date: May 2007
Posts: 29
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, 01:40 PM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Greece
Posts: 353
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, 09:51 AM
Junior Member
 
Join Date: May 2007
Posts: 29
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, 10:10 AM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Greece
Posts: 353
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
A few questions regarding FormLib N1c0_ds Questions & Help Needed 6 09-19-2008 03:34 AM
Newbie Questions Bruno Questions & Help Needed 2 05-05-2008 07:45 PM
Questions on SpecialKeys HARRY Questions & Help Needed 5 02-26-2008 02:55 PM
One of my stupid questions.... Cableguy Questions & Help Needed 7 01-27-2008 11:26 AM
More SQL questions HARRY Questions & Help Needed 2 01-04-2008 11:15 AM


All times are GMT. The time now is 01:03 PM.


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