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.


Command to create a database in sqlite


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-24-2008, 09:41 AM
Senior Member
 
Join Date: Mar 2008
Posts: 103
Default Command to create a database in sqlite

Hi,

A silly asking. I found the command to create a table using sqlite,but what about to
create a database?

The table would be stored in the sqlite_master table.

What is the "full path" of the database/table to connect using Basic4ppc 6.05.


Please help.


regards,

Last edited by mozaharul : 03-24-2008 at 09:46 AM.
Reply With Quote
  #2 (permalink)  
Old 03-24-2008, 10:42 AM
giannimaione's Avatar
Senior Member
 
Join Date: Apr 2007
Location: Naples, Italy
Posts: 155
Send a message via Skype™ to giannimaione
Awards Showcase
Beta Tester 
Total Awards: 1
Smile

MyPath = AppPath :' or any path .... MyPath="c:\MyJobs\Alfa\Beta\Gamma"
Connect.New1
Command.New1 ("",Connect.Value)
Connect.Open("Data Source = " & MyPath & "\MyDB.sl3"):' here open or create database named MyDb.sl3
Text="create table if not exists MyTable (Field1 text, Field2 text)"
Command.CommandText=Text
Command.ExecuteNonQuery
'here open or create a simple table

.
.
.
.

of course, use SQLDevice.dll or SQLDesktop.dll
__________________
Gianni Maione

Last edited by giannimaione : 03-24-2008 at 10:46 AM.
Reply With Quote
  #3 (permalink)  
Old 03-25-2008, 03:42 AM
Senior Member
 
Join Date: Mar 2008
Posts: 103
Default

Hi Gianni Maione,

Thanks a lot for the help.
Reply With Quote
  #4 (permalink)  
Old 03-27-2008, 11:01 AM
Senior Member
 
Join Date: Mar 2008
Posts: 103
Default

Another question:

I created the connection to a database as like:

Sub App_Start
Form1.Show
'Setting connection to the database
con.New1
cmd.New1("",con.Value)
con.Open("data source =" & AppPath & "\kamlapur.sl3")

..........

end sub

I want use a button to save the data from few combo boxes and text boxes to the above database. How shold I write the INSERT command in the click event of the button? I tried some thing like:

Sub msave_Click
If cmbstar.SelectedIndex = -1 Then
Msgbox ("No staturm Selected","Error")
cmbstar.Focus
Else If cmbclu.SelectedIndex= -1 Then
Msgbox ("No Cluster Selected","Error")
cmbclu.Focus
Else If txthhid.Text="" Then
Msgbox ("No Structure Selected","Error")
txthhid.Focus
Else If txtiid.Text="" Then
Msgbox ("No HH No. Selected","Error")
txtiid.Focus
Else If txthhidtn.Text="" Then
Msgbox ("No HH ID Selected","Error")
txthhidtn.Focus
Else
cmd.CommandText=insert into kamlapur.sl3 values(cmbstar.SelectedIndex,cmbclu.SelectedIndex, txthhid.Text,txtiid.Text,txthhidtn.Text)
cmd.ExecuteTable(kamlapur.sl3,500)
'table1.AddRow (cmbstar.SelectedIndex,cmbclu.SelectedIndex,txthhi d.Text,txtiid.Text,txthhidtn.Text)
'table1.SaveCSV(dataFile,",",true)
End If
End Sub

But it gives error message.
could you suggest the correct syntax?

your help is highly appreciated.


regards,
Reply With Quote
  #5 (permalink)  
Old 03-27-2008, 01:52 PM
giannimaione's Avatar
Senior Member
 
Join Date: Apr 2007
Location: Naples, Italy
Posts: 155
Send a message via Skype™ to giannimaione
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Sub App_Start
Form1.Show
'Setting connection to the database
con.New1
cmd.New1("",con.Value)
con.Open("data source =" & AppPath & "\kamlapur.sl3"):' ok open database
.
.
end sub


Sub msave_Click
.
.
text="insert into NameTable (Field1, Field2) values ("
text=text & MyData1 & "," & MyData2 & ")"
msgbox(text):'only for test
cmd.CommandText=text
cmd.ExecuteNonQuery
End Sub
__________________
Gianni Maione
Reply With Quote
  #6 (permalink)  
Old 03-30-2008, 04:38 AM
Senior Member
 
Join Date: Mar 2008
Posts: 103
Default

Hi Gianni Maione,

I made following changes in the code:

Sub App_Start
Form1.Show
dbpath="C:\Documents and Settings\mozaharul\Desktop"
con.New1
cmd.New1("",con.Value)
con.Open("data source =" & dbpath & "\kamlapur.sl3")
TFields="strat numeric, cluster numeric, struct numeric, hhid numeric,hpid numeric"
Txt="create table if not exists geo (" & TFields & ")"
cmd.CommandText=Txt
cmd.ExecuteNonQuery

end sub

... ...
... ...

then :

Sub msave_Click
If cmbstar.SelectedIndex = -1 Then
Msgbox ("No staturm Selected","Error")
cmbstar.Focus
Else If cmbclu.SelectedIndex= -1 Then
Msgbox ("No Cluster Selected","Error")
cmbclu.Focus
Else If txthhid.Text="" Then
Msgbox ("No Structure Selected","Error")
txthhid.Focus
Else If txtiid.Text="" Then
Msgbox ("No HH No. Selected","Error")
txtiid.Focus
Else If txthhidtn.Text="" Then
Msgbox ("No HH ID Selected","Error")
txthhidtn.Focus
Else
cmd.CommandText = "insert into geo values(cmbstar.Item(cmbstar.SelectedIndex)","cmbcl u.Item(cmbclu.SelectedIndex)","txthhid.Text","txti id.Text","txthhidtn.Text)"
cmd.ExecuteNonQuery
End If
End Sub

Sub Form1_Close
con.Close
End Sub


the code executes without any error,but no data is being saved in the "geo" table in the desktop.

Could you help finding the error in the syntax?


regards,

Last edited by mozaharul : 03-30-2008 at 10:03 AM.
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
Graphic in SQLite Database Picard Questions & Help Needed 1 08-23-2008 12:03 PM
Help on Sqlite Update Command jeterry Questions & Help Needed 13 03-31-2008 09:45 AM
how to create a database ? gjoisa Questions & Help Needed 27 02-14-2008 06:38 PM
Tool to create, edit , modify table and registers in sqlite 3 tucano2000 Code Samples & Tips 0 02-12-2008 01:11 PM
How to convert an Access database to a sqlite database Peter Code Samples & Tips 5 07-24-2007 04:20 PM


All times are GMT. The time now is 03:26 AM.


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