Page 1 of 1
Database's or something easier ?
Posted: Fri Sep 23, 2005 3:35 pm
by BOOGIEMAN
I want to make program for a computer store. Basicly, it must have ability to accept input of PC components (monitors, graphic cards, motherboards ... etc), every component must have price. Now, I want something like to choose components from a list and than see sum price and than to print it all.
The problem is: Where do I start ?? I want simpliest possible solution, I've looked some database examples from codearhive but most of them aren't working or they are in German. I would be happiest if I could somehow avoid database learning, if I could store my data in a .txt file or something like that. Any good turtorial for a newbie ?
Posted: Fri Sep 23, 2005 4:42 pm
by the.weavster
I think you'll find working with databases much easier than working with text files.
go to
www.purearea.net and check out the English code archive for examples.
Posted: Fri Sep 23, 2005 5:13 pm
by BOOGIEMAN
the.weavster wrote:I think you'll find working with databases much easier than working with text files.
go to
www.purearea.net and check out the English code archive for examples.
Yes, that's the one I have. It's very confusing for a newbie and lots of code doesn't work with PB 3.94. That codearhive should be updated more often
Posted: Fri Sep 23, 2005 5:16 pm
by Paul
Did you look at the MDB_Lib on the
http://www.pureproject.net website?
Posted: Fri Sep 23, 2005 7:57 pm
by Beach
Using the MDB_lib would be the ticket. Once setup, it would be much easier to deal with than files (IMHO). Yep, quick and easy database access. Thanks again for the lib Paul!

Posted: Fri Sep 23, 2005 8:17 pm
by BOOGIEMAN
Beach wrote:Using the MDB_lib would be the ticket. Once setup, it would be much easier to deal with than files (IMHO). Yep, quick and easy database access. Thanks again for the lib Paul!

Hmm, can you give me some more examples than MDBLib Demo/Sample.pb ?
Posted: Fri Sep 23, 2005 8:20 pm
by Droopy
Ldb functions included in the Droopy Lib is an easy way for beginner

Posted: Fri Sep 23, 2005 8:33 pm
by jb
Yes and the MDB_Lib will also work with mySQL databases.
I have used the SQLite3 library from the PureBasic Open Source Library and have found it very easy to use. It is nice for single user databases.
http://pbosl.purearea.net/
Posted: Fri Sep 23, 2005 11:15 pm
by BOOGIEMAN
I wonder how did you manage to start any examples from "pbosl_examples" ??
When I try to compile "PBOSL_sqlite3_test.pb" this error ocurs:
Line 11:SQLite3_Init() is not a function, an array, or a linked list
Also when I try to start "Get_mdb_data_Tool.pb" error:
Line 177:MakeConnection() is not a function, an array, or a linked list
It's too late now, I'll try Droopy's library tomorrow
Posted: Fri Sep 23, 2005 11:50 pm
by ts-soft
BOOGIEMAN wrote:I wonder how did you manage to start any examples from "pbosl_examples" ??
When I try to compile "PBOSL_sqlite3_test.pb" this error ocurs:
Line 11:SQLite3_Init() is not a function, an array, or a linked list
Also when I try to start "Get_mdb_data_Tool.pb" error:
Line 177:MakeConnection() is not a function, an array, or a linked list
It's too late now, I'll try Droopy's library tomorrow
when I compile "PBOSL_sqlite3_test.pb"

Posted: Sat Sep 24, 2005 12:54 am
by jb
Are you sure that you installed the library properly? I am having no problems compiling/running the example.
Posted: Sat Sep 24, 2005 3:35 am
by rsts
BOOGIEMAN wrote:I wonder how did you manage to start any examples from "pbosl_examples" ??
When I try to compile "PBOSL_sqlite3_test.pb" this error ocurs:
Line 11:SQLite3_Init() is not a function, an array, or a linked list
Also when I try to start "Get_mdb_data_Tool.pb" error:
Line 177:MakeConnection() is not a function, an array, or a linked list
It's too late now, I'll try Droopy's library tomorrow
This is what you get if you try to run the example without installing the library (and, in my case, then removing the "duplicate" references).
cheers
Posted: Mon Sep 26, 2005 11:43 pm
by jb
BOOGIEMAN here is a small code sample using the PBOSL SQLite3 library.
Code: Select all
;Window Constants
Enumeration
#Window_Main
EndEnumeration
;Gadget Constants
Enumeration
#Text_Name
#Text_City
#String_Name
#String_City
#Button_Save
EndEnumeration
;Recordset structure
Structure RecordSet
BOF.l
EOF.l
Handle.l
Rows.l
Cols.l
CurrentPos.l
Value.s
EndStructure
Procedure Open_Window_Main()
If OpenWindow(#Window_Main, 241, 37, 305, 121, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "Database Sample")
If CreateGadgetList(WindowID())
TextGadget(#Text_Name, 10, 10, 50, 20, "Name:")
TextGadget(#Text_City, 10, 40, 50, 20, "City:")
StringGadget(#String_Name, 60, 10, 210, 20, "")
StringGadget(#String_City, 60, 40, 210, 20, "")
ButtonGadget(#Button_Save, 110, 70, 80, 25, "Save")
EndIf
EndIf
EndProcedure
;main
If SQLite3_Init() = #False
MessageRequester("Data Sample", SQLite3_GetLastMessage())
End
EndIf
dbName$ = "Sample.db"
;open database
dbHandle.l = SQLite3_OpenDatabase(dbName$)
If dbHandle = 0
;create new database
dbHandle = SQLite3_CreateDatabase(dbName$, #True)
If dbHandle = 0
MessageRequester("Data Sample", SQLite3_GetLastMessage())
End
EndIf
EndIf
;create the Client table
SQL$ = "CREATE TABLE Sample (Name, City)"
SQLite3_Execute(SQL$, dbHandle)
Open_Window_Main()
Repeat ; Start of the event loop
Event = WaitWindowEvent()
GadgetID = EventGadgetID()
If Event = #PB_EventGadget
If GadgetID = #Button_Save
;get gadget values
Name$ = Trim(GetGadgetText(#String_Name))
City$ = Trim(GetGadgetText(#String_City))
SQLite3_Execute("BEGIN TRANSACTION", dbHandle)
SQL$ = "INSERT INTO Sample (Name, City) VALUES ('" + Name$ + "', '" + City$ + "')"
SQLite3_Execute(SQL$, dbHandle)
SQLite3_Execute("COMMIT TRANSACTION", dbHandle)
;make sure record was added
If SQLite3_GetLastMessage() = "OK"
MessageRequester("Data Sample", "Record Added")
SetGadgetText(#String_Name,"")
SetGadgetText(#String_City,"")
Else
MessageRequester("Data Sample", SQLite3_GetLastMessage())
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow ; End of the event loop
;close database
SQLite3_CloseDatabase(dbHandle)
SQLite3_End()
End
;
I hope this helps.
Posted: Tue Sep 27, 2005 1:34 am
by Karbon
Or, you could grab kBilling!

Posted: Tue Sep 27, 2005 11:35 am
by Num3
Ehehehe
