Database's or something easier ?

Just starting out? Need help? Post your questions and find answers here.
BOOGIEMAN
User
User
Posts: 24
Joined: Sun Aug 07, 2005 10:29 pm
Location: Earth

Database's or something easier ?

Post 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 ?
User avatar
the.weavster
Addict
Addict
Posts: 1577
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Post 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.
BOOGIEMAN
User
User
Posts: 24
Joined: Sun Aug 07, 2005 10:29 pm
Location: Earth

Post 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
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Did you look at the MDB_Lib on the http://www.pureproject.net website?
Image Image
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post 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! :D
-Beach
BOOGIEMAN
User
User
Posts: 24
Joined: Sun Aug 07, 2005 10:29 pm
Location: Earth

Post 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! :D
Hmm, can you give me some more examples than MDBLib Demo/Sample.pb ?
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

Ldb functions included in the Droopy Lib is an easy way for beginner 8)
jb
User
User
Posts: 37
Joined: Wed Jul 14, 2004 11:58 pm
Location: United States

Post 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/
-jb
BOOGIEMAN
User
User
Posts: 24
Joined: Sun Aug 07, 2005 10:29 pm
Location: Earth

Post 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
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post 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"
Image :?:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
jb
User
User
Posts: 37
Joined: Wed Jul 14, 2004 11:58 pm
Location: United States

Post by jb »

Are you sure that you installed the library properly? I am having no problems compiling/running the example.
-jb
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post 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
jb
User
User
Posts: 37
Joined: Wed Jul 14, 2004 11:58 pm
Location: United States

Post 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.
-jb
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Or, you could grab kBilling! :-)
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Ehehehe :lol:
Post Reply