-VB 6.0 Professional
-Microsoft DAO 3.6 Reference
Add to Database table...
An attempt to submit data to Access database:
(1) This program attempts to add, delete, update data to the Access database
(2) Build an Access database table with 5 text fields
(3) Read code below, add these fields starting with Your_Price as names
(4) Each field must correspond with the field names shown here in VB
(5) You must have an array of 5 textboxes, first in line Text1(0).Text
(6) You will need a fancy command button called whatever you want, 'Seek'
(7) ADD Microsoft DAO 3.6 Object Library
(8) Add code below...
-
-
Private Sub subt_Click() 'this function will load entry into database
-
'dim as database to allow vb to interact with Access database seemlessly...
-
Dim my_database As Database
-
'open database to allow vb to add data to Access database seemlessly...
-
Set my_database = OpenDatabase("C:\DataGram\Data_Central.mdb")
-
'run insert statement query that will load data to your database
-
my_database.Execute "insert into Data_Central.LIBRARY(Your_Price, Name, Type, Crime_Rate_1, Crime_Rate_2) Values('" & Text1(0).Text & "','" & Text1(1).Text & "' , '" & Text1(2).Text & "' , '" & Text1(3).Text & "','" & Text1(4).Text & "')"
-
my_database.Close
-
'this variable serves to emptying your textboxes, part of reset button
-
R_Click
-
-
End Sub
-
-
Delete Data from database... -
-
Private Sub dll_Click()
-
'dim as database to allow vb to interact with Access database seemlessly...
-
Dim my_database As Database
-
'dim as Recordset to allow vb to interact with Access database seemlessly...
-
Dim my_record As Recordset
-
'open database to allow vb to delete data from Access database seemlessly...
-
Set my_database = OpenDatabase("C:\DataGram\Data_Central.mdb")
-
'run delete statement query that will remove data from your database
-
Set my_record = my_database.OpenRecordset("select * from LIBRARY where Your_Price='" & Text1(0).Text & "'")
-
If Not my_record.EOF Then
-
my_record.Delete
-
End If
-
my_database.Close
-
'variable that should empty textboxes for future instances...
-
R_Click
-
-
End Sub
-
-
Update Data in database... -
-
Private Sub Updt_Click()
-
'dim as database to allow vb to interact with Access database seemlessly...
-
Dim my_database As Database
-
'dim as Recordset to allow vb to interact with Access database seemlessly...
-
Dim my_record As Recordset
-
'run a little check to see if proper credentials are added before releasing info...
-
If (Text1(0) = "") Then
-
MsgBox ("Please put in Your price..."), vbOKOnly, "Data Mining Error"
-
ElseIf (Text1(1) = "") Then
-
MsgBox ("Please put in Item name..."), vbOKOnly, "Data Mining Error"
-
Else
-
'open database to allow vb to update data to Access database seemlessly...
-
Set my_database = OpenDatabase("C:\DataGram\Data_Central.mdb")
-
'run update statement query that will modify data to your database
-
Set my_record = my_database.OpenRecordset("SELECT * FROM LIBRARY WHERE Your_Price='" & Text1(0).Text & "'")
-
my_record.Edit
-
my_record!Your_Price = Text1(0).Text
-
my_record!Name = Text1(1).Text
-
my_record!Type = Text1(2).Text
-
my_record!Crime_Rate_1 = Text1(3).Text
-
my_record!Crime_Rate_2 = Text1(4).Text
-
-
my_record.Update
-
my_record.Close
-
my_database.Close
-
-
End If
-
-
End Sub
-
-
Clear your textboxes... -
Private Sub R_Click() 'this must clear the textbox upon entry of all data
-
Text1(0).Text = ""
-
Text1(1).Text = ""
-
Text1(2).Text = ""
-
Text1(3).Text = ""
-
Text1(4).Text = ""
-
-
Text1(0).SetFocus 'this should set index back to first textbox
-
End Sub
-
Convert Data to XML file next...
-Add Microsoft XML v 3.0
-Add code below
Contiued from:
http://www.thescripts.com/forum/thread777267.html
-VB 6.0 Professional
-Microsoft XML v3.0 Reference
Converting Access Data to XML file...
An attempt to convert data from Access database to XML:
(1) This program attempts to transform Access data to XML
(2) Use Existing database table, load above code
(4) Each field must correspond with the field names shown here in VB
(5) You will need a fancy command button called whatever you want, 'Seek'
(6) ADD Microsoft XML v3.0 Object Library, in References
(7) Add Microsoft DAO 3.6 Object Library
(8) Add code below...
-
-
-
Private Sub CreateXMFile_Click()
-
'dim as database to allow vb to interact with Access database seemlessly...
-
Dim my_database As Database
-
'dim as Recordset to allow vb to interact with Access database seemlessly...
-
Dim objRS As Recordset
-
dimension your FreeFile
-
Dim intFreeFile
-
'open database to allow vb to grab data from Access database seemlessly...
-
Set my_database = OpenDatabase("C:\DataGram\Data_Central.mdb")
-
'run query that will collect data from your database
-
Set objRS = my_database.OpenRecordset("SELECT Your_Price, Name, Type, Crime_Rate_1, Crime_Rate_2 From LIBRARY")
-
intFreeFile = FreeFile
-
Open App.Path + "\App_Price.xml" For Output As #intFreeFile
-
-
'build XML version number, and print column names for readibility...
-
Print #intFreeFile, "<?xml version=" & Chr(34) & "1.0" & Chr(34) & "?>"
-
Print #intFreeFile, "<!-- File Name: App_Price.xml -->"
-
-
'printing out nodes and subnodes with data gathered from database...
-
Print #intFreeFile, "<Find_It>"
-
-
Do While Not objRS.EOF
-
Print #intFreeFile, "<Apartmnt>"
-
Print #intFreeFile, "<Your_Price>" & objRS.fields("Your_Price") & "</Your_Price>" _
-
& vbCrLf & "<Name>" & objRS.fields("Name") & "</Name>" & vbCrLf & "<Type>" & objRS.fields("Type") & "</Type>" _
-
& vbCrLf & "<Crime_Rate_1>" & objRS.fields("Crime_Rate_1") & "</Crime_Rate_1>" _
-
& vbCrLf & "<Crime_Rate_2>" & objRS.fields("Crime_Rate_2") & "</Crime_Rate_2>"
-
Print #intFreeFile, "</Apartmnt>"
-
objRS.MoveNext
-
Loop
-
-
Print #intFreeFile, "</Find_It>"
-
-
objRS.Close
-
Set objRS = Nothing
-
Close intFreeFile
-
MsgBox ("What do you know, you have an XML file!")
-
'depending on number of instances added in input box upon entry,
-
'you will have x amount of instances to enter, browse data through this application. Button disappears after your max has been reached:-)
-
If (prs_calc = ndvdl) Then 'this logic will take away button CreateXMFile if limit has been reached
-
CreateXMFile.Visible = False
-
End If
-
End Sub
-
-
See next: http://bytes.com/forum/thread777278.html