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.


how to create a database ?


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-13-2008, 11:18 AM
gjoisa's Avatar
Knows the basics
 
Join Date: Feb 2008
Location: Udupi , India
Posts: 53
Default how to create a database ?

Hi I am writing an astrology program for which i need a database containing latitude longitude informations . Required fields are :
1. Name of the Place eg:Mumbai
2. Latitude (Degrees , minutes , North or South)eg:18:58 N
3. Longitude (degrees , Minutes , West or East)eg:72:50 E
4. Timezone (Hours and minutes)eg:+5:30
How to create it ?
Reply With Quote
  #2 (permalink)  
Old 02-13-2008, 12:24 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,973
Default

For small - medium databases I recommend you to use the Table control.
You can create a CSV (comma separated file) with any text editor and then load it to the table with Table.LoadCSV.

For large databases you should use the SQL library.
Reply With Quote
  #3 (permalink)  
Old 02-13-2008, 12:35 PM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 130
Default

Hi Gjoisa,

the easiest way to do it is to use a comma delimited file (for small databases).

Put a table-control on the form you will be using and then create the table by adding columns to it e.g.:
table1.AddCol (cString, "PlaceName", 0) and so on for each column you want to add (the syntax is under "addcol", under "table" in the helpfile)

Once you have created the columns in the table you can fill it with data (see "cell" under "table" in the helpfile)

Finally you save it with e.g.
table1.SaveCSV, e.g. Table1.SaveCSV ("Astrology.csv", ",", True)
once again the syntax is in the helpfile. The resulting file can be read by any text editor e.g. notepad.

I assure you, it is very straightforward - to my mind that is what makes it so nice to work with Basic4ppc

Good luck ! / Björn

Edit: As always Erel succeeds in answering first - but this time your comment is shorter than mine !
Reply With Quote
  #4 (permalink)  
Old 02-14-2008, 07:14 AM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 200
Default

Just a question that pops into mind: is there a way to create a CSV-database, using the FileWrite method? I know I can write a comma after each entry but in the textmode each entry takes up a line. I want to see the data after one another in textmode (as if opened by a texteditor). Is that possible?
Reply With Quote
  #5 (permalink)  
Old 02-14-2008, 07:43 AM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 130
Default

Hi Stellarefox,

I think so, these lines write 10 lines in three columns, separated by a comma. Is that what you were asking for?

FileOpen(c1,AppPath&"\test.csv",cWrite)
For i=0 To 10
FileWrite(c1,"This is record "&i&" col 1, This is record "&i&" col 2, This is record "&i&" col 3")
Next
FileClose(c1)

all the best / Björn
Reply With Quote
  #6 (permalink)  
Old 02-14-2008, 08:01 AM
gjoisa's Avatar
Knows the basics
 
Join Date: Feb 2008
Location: Udupi , India
Posts: 53
Default

can you tell me with example to create database with SQL ?
Reply With Quote
  #7 (permalink)  
Old 02-14-2008, 08:23 AM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 130
Default

Dear Gjoisa,

there is actually quite a good example in the helpfile, but here is a something I have used myself:

con.New1
cmd.New1("",con.Value)
con.Open("Data Source = " & DataF)

TableFields="Cat text, Title text, Note text, Deadline text"
Txt="create table if not exists MainTable (" & TableFields & ")"
cmd.CommandText=Txt
cmd.ExecuteNonQuery
cmd.CommandText="create table if not exists CatTable (Dummy text, Vis integer, Cat text)"
cmd.ExecuteNonQuery

It tries to open DataF. If the file does not exist or the database doesn't exist then it creates a database with two tables (MainTable and CatTable), the first with four fields and the second with three fields (the "text" is put in there to give the type of field). The database is opened with filename DataF.

But may I suggest that you have a look at the helpfile - it is really quite helpful

all the best / Björn
Reply With Quote
  #8 (permalink)  
Old 02-14-2008, 08:54 AM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 200
Default

Hi Bjorn,

That is the problem, the FileWrite only takes one parameter at the time and moves on to the next line with a CRLF.
Marc
Reply With Quote
  #9 (permalink)  
Old 02-14-2008, 09:02 AM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 130
Default

Hi Marc,

but if you write it all together (e.g. "this is col1, this is col2, this is col3") then you will end up with three columns if you open this as a database.

If this isn't what you were asking about then I'm afraid I didn't understand the question, could you explain further?

all the best / Björn
Reply With Quote
  #10 (permalink)  
Old 02-14-2008, 09:14 AM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 200
Default

Yes you're right there, but I want to read the file using the SplitString feature on the comma's and it won't look "into" the string if there are any comma's. I want to separate the entries with comma's in one long line actually, just as CSV files.
marc
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
No way to create a recurring appointment? kolbe Questions & Help Needed 2 07-02-2008 06:43 PM
How to create a new appointment willisgt Questions & Help Needed 2 05-15-2008 08:21 PM
Command to create a database in sqlite mozaharul Questions & Help Needed 5 03-30-2008 03:38 AM
Can you help me create B4P lib? conf Questions & Help Needed 7 08-20-2007 07:41 PM
How to convert an Access database to a sqlite database Peter Code Samples & Tips 5 07-24-2007 03:20 PM


All times are GMT. The time now is 10:12 PM.


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