VB6.0 ado coding

MS access07 connect with vb6.0

Page 1 of 1

4 Replies - 7033 Views - Last Post: 26 March 2012 - 02:48 PM Rate Topic: -----

#1 Guest_VRV*


Reputation:

VB6.0 ado coding

Posted 24 August 2010 - 11:15 PM

I need coding to delete records from MS-Access 2007 from VB 6.0 using ADO
Help me
Is This A Good Question/Topic? 0

Replies To: VB6.0 ado coding

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10596
  • View blog
  • Posts: 39,259
  • Joined: 27-December 08

Re: VB6.0 ado coding

Posted 25 August 2010 - 06:37 AM

The VB6 Tutorials Section is a great place to start. I believe we have a couple of VB6 with MS-Access tutorials. After you read the tutorials, try writing the code. We will be happy to help you with your good faith efforts if you run into trouble.
Was This Post Helpful? 0
  • +
  • -

#3 parbipin  Icon User is offline

  • D.I.C Head

Reputation: 29
  • View blog
  • Posts: 95
  • Joined: 23-August 10

Re: VB6.0 ado coding

Posted 25 August 2010 - 03:50 PM

You will need to update the SQL and Database Path in the code.
If it helps please rate it!!!!


Sub DeleteSomeRecordsADO()
Dim cnn As ADODB.Connection
Dim cmdCommand As ADODB.Command
Dim vtSql
Dim DbConnection as String, DbSource as String

DbSource = "Path to your Database should be here!!!"
DbConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DbSource & ";"
    
    '' Open the connection.
    Set cnn = New ADODB.Connection
    cnn.Open DbConnection

    '' Set the command text.
    Set cmdCommand = New ADODB.Command
    Set cmdCommand.ActiveConnection = cnn

    '' - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    vtSql = ""
    vtSql = vtSql & " DELETE * "
    vtSql = vtSql & " FROM MyTable "
    vtSql = vtSql & " WHERE MyField='MyValue'"
        
    With cmdCommand
        .CommandText = vtSql
        .CommandType = adCmdText
        .Execute
    End With

    '' Close the connections and clean up.
    cnn.Close
    Set cmdCommand = Nothing
    Set cnn = Nothing
    
End Sub



Was This Post Helpful? 1
  • +
  • -

#4 ellaandcodeysdaddy  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 18
  • Joined: 21-March 12

Re: VB6.0 ado coding

Posted 21 March 2012 - 10:38 PM

Will this method work with Microsoft.Ace.12.0 ? I'm trying to write something similar in javascript using Access 2007?

View Postparbipin, on 25 August 2010 - 03:50 PM, said:

You will need to update the SQL and Database Path in the code.
If it helps please rate it!!!!


Sub DeleteSomeRecordsADO()
Dim cnn As ADODB.Connection
Dim cmdCommand As ADODB.Command
Dim vtSql
Dim DbConnection as String, DbSource as String

DbSource = "Path to your Database should be here!!!"
DbConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DbSource & ";"
    
    '' Open the connection.
    Set cnn = New ADODB.Connection
    cnn.Open DbConnection

    '' Set the command text.
    Set cmdCommand = New ADODB.Command
    Set cmdCommand.ActiveConnection = cnn

    '' - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    vtSql = ""
    vtSql = vtSql & " DELETE * "
    vtSql = vtSql & " FROM MyTable "
    vtSql = vtSql & " WHERE MyField='MyValue'"
        
    With cmdCommand
        .CommandText = vtSql
        .CommandType = adCmdText
        .Execute
    End With

    '' Close the connections and clean up.
    cnn.Close
    Set cmdCommand = Nothing
    Set cnn = Nothing
    
End Sub



Was This Post Helpful? 0
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: VB6.0 ado coding

Posted 26 March 2012 - 02:48 PM

This is the general way to handle deletes using ADO and Access, yes. Should work for you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1