• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

Save,Edit and Delete database.

Hi,

I use Vb6 Data1 to Data5 control to open foxpro database. after do some sql work then i need to save it into Access 2000 database which i already open with Data6 and Data7.

pls advice how do Save,Edit and Delete database using data control.
0
aarontham
Asked:
aarontham
  • 4
  • 3
  • 2
1 Solution
 
MYLimCommented:
experts here will strongly comment you using ADODB method.
and this method very easy thing to achive to fulfill your requirement.

[Delete]
Conn.execute "Delete from table where filed=12345"

[Add]
Conn.execute "Insert into (Field1,Field2) values (1,2)"

[Save & Edit]
Conn.execute "Update Table1 set Fielda=12345 where fielda=45678"
0
 
MYLimCommented:
0
 
MYLimCommented:
This code will explain is basically for beginers to master ADODB coding in few minutes. This code will explain how to CONNECT access database, how to generate query, how to traverse the records (that is moveFirst, MoveNext, and so...), how to delete recor ...(description truncated)

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=48747&lngWId=1

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
leonstrykerCommented:
Good advice from MYLim
0
 
MYLimCommented:
thank's Leon
0
 
aaronthamAuthor Commented:
Hi Guys,

If i use ADODB method would i have problem when i compile the program as i already have the whole program open with Data control. pls advice.

Thank You
 
0
 
leonstrykerCommented:
Youy should get rid of the data control, it will only cause you more greef in the future.
0
 
aaronthamAuthor Commented:
Dear Leonstryker,

Pls help me to get rid of the data control, my code is as below pls advice. what code should it use.



Private Sub Form_Load()
Dim strQuery As String
Dim strQuery1 As String
Dim criteria As String
Dim strQuery2 As String
Dim strQuery3 As String



criteria = ""
strQuery = ""
strQuery1 = ""
criteria = ""
strQuery2 = ""
strQuery3 = ""



Me.WindowState = vbMaximized

 ProgramActivation
  Call SaveActivityToLogDB("Start access Operator menu.")
  Call Message("This menu is for user who has level: 'Operator' and 'Admin' .")
 

cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Quote.mdb;Jet OLEDB:Database Password=mssb18"
cnn.Open

 
   ListView1.ColumnHeaders.Add , , "Capacity", ListView1.width / 4.5
   ListView1.ColumnHeaders.Add , , "Td Part", ListView1.width / 6, lvwColumnCenter
   ListView1.ColumnHeaders.Add , , "Original Part", ListView1.width / 6, lvwColumnCenter

   
     ListView1.View = lvwReport
     
     
 

InitSubClass
Set objLabelEdit = New LabelEdit
objLabelEdit.Init Me, ListView1


'Load data into combo1 (Class)
strQuery = "SELECT DISTINCT descrip1 From pl002 "


Combo1.Clear
Data2.RecordSource = strQuery
Data2.Refresh
If Not Data2.Recordset.EOF Then
Data2.Recordset.MoveFirst

    Do Until Data2.Recordset.EOF
        Combo1.AddItem IIf(IsNull(Data2.Recordset.Fields("DESCRIP1")), "", Data2.Recordset.Fields("DESCRIP1"))
        Data2.Recordset.MoveNext
    Loop
  End If
   
'Load Data Into List1 (Brand)
strQuery1 = "Select * From PL001 "


    criteria = " Where (OEM) Like '" + (Text1.Text) + "*'" ' Create the criteria.


List1.Clear
Data1.RecordSource = strQuery1 & criteria
Data1.Refresh
If Not Data1.Recordset.EOF Then
    Data1.Recordset.MoveFirst
    Do Until Data1.Recordset.EOF
        List1.AddItem Data1.Recordset.Fields("OEM")
        Label2 = Data1.Recordset.Fields("OEMID")
        Data1.Recordset.MoveNext
    Loop
End If


'Load Data Into List2 (Model)

strQuery2 = "SELECT model from pl002 ORDER BY pl002.model"

List2.Clear
Data2.RecordSource = strQuery2 '& criteria2
Data2.Refresh
If Not Data2.Recordset.EOF Then
    Data2.Recordset.MoveFirst
    Do Until Data2.Recordset.EOF
        List2.AddItem Data2.Recordset.Fields("MODEL")
        Data2.Recordset.MoveNext
    Loop

End If


strQuery3 = "SELECT company from cusadd ORDER BY company"
List3.Clear
Data6.RecordSource = strQuery3
Data6.Refresh
If Not Data6.Recordset.EOF Then
    Data6.Recordset.MoveFirst
    Do Until Data6.Recordset.EOF
   List3.AddItem IIf(IsNull(Data6.Recordset.Fields("company")), "", Data6.Recordset.Fields("company"))
        Data6.Recordset.MoveNext
    Loop

End If



End Sub
0
 
aaronthamAuthor Commented:


I plan to run my program in a network with about 5 to 10 user. pls advice the right code.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now