I'm new to PureBasic and I decided to develop an application that needs secure database, so i decided to use Access database instead of SQlite, and finally i used the MDB_Lib by Paul Leischow because its easy, but i need to know how to add a user and password to the database, i tried different ways such as:
Code: Select all
DatabaseQuery(db,"ALTER DATABASE PASSWORD newpassword NULL")
and
DatabaseQuery(db,"ALTER USER user PASSWORD newpassword NULL")
Here my code:
Code: Select all
;/ Created with PureVisionXP v4.00
;/ Thu, 08 Jun 2006 19:22:42
;/ by Reel Media Productions
XIncludeFile "Demo_Constants.pb"
XIncludeFile "Demo_Windows.pb"
Global db.l
curdir.s=GetCurrentDirectory()
idx=1
total=3
Procedure Form_Fill(id.l)
qry.s="Select name,phone from Info where id="+Str(id)
If DatabaseQuery(db,qry)
If NextDatabaseRow(db)
SetGadgetText(#Gadget_Main_Name,GetDatabaseString(db,0))
SetGadgetText(#Gadget_Main_Phone,GetDatabaseString(db,1))
EndIf
EndIf
EndProcedure
;MDB_Create(curdir+"Test")
db=MDB_Connect(curdir,"Test","","currpassword")
If db=0
MessageRequester("Error","Could Not Connect to Database",#MB_ICONERROR)
End
EndIf
qry.s="Create table Info(id autoincrement,name text(100),phone text(50),"
qry+"constraint Info unique(id));"
If DatabaseQuery(db,qry)
DatabaseQuery(db,"ALTER DATABASE PASSWORD newpassword currpassword")
DatabaseQuery(db,"Insert into Info(name,phone)values('Paul','555-1234')")
DatabaseQuery(db,"Insert into Info(name,phone)values('Fred','555-0098')")
DatabaseQuery(db,"Insert into Info(name,phone)values('Joey','555-4455')")
EndIf
;- Main Loop
If Window_Main()
Form_Fill(idx)
quitMain=0
Repeat
EventID =WaitWindowEvent()
MenuID =EventMenu()
GadgetID =EventGadget()
WindowID =EventWindow()
Select EventID
Case #PB_Event_CloseWindow
If WindowID=#Window_Main
quitMain=1
EndIf
Case #PB_Event_Gadget
Select GadgetID
Case #Gadget_Main_Back
idx-1
If idx<1
idx=1
EndIf
Form_Fill(idx)
Case #Gadget_Main_Next
idx+1
If idx>total
idx=total
EndIf
Form_Fill(idx)
EndSelect
EndSelect
Until quitMain
CloseWindow(#Window_Main)
EndIf
CloseDatabase(db)
MDB_Disconnect("Test")
End

Thanks,