Results 1 to 6 of 6

Thread: [RESOLVED] - running a delete query with a dsn

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2002
    Posts
    586

    [RESOLVED] - running a delete query with a dsn

    Greetings,

    I need to set up , in VB6, a delete query through a dsn. How do I say it in code? Here is the dsn and the query that will be run.

    dsn="mbdb_mb"

    sql = "TRUNCATE TABLE LRUCache" 'deletes records in table, without checking for foreign keys

    Thank you,
    Jim
    Last edited by JimMuglia; Jun 14th, 2007 at 12:52 PM. Reason: resolved

  2. #2

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2002
    Posts
    586

    Re: running a delete query with a dsn

    Quote Originally Posted by RhinoBull
    What type of database do you have?
    But you really don't need any dsn at all - you can use ado connection or command object to execute your sql.
    See link in my signature for proper connection string.
    SQL Server 2000 database.

    Need to use dsn as it goes by company standards. Don't have a choice.

    Thanks,
    Jim

  4. #4

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2002
    Posts
    586

    [RESOLVED] - running a delete query with a dsn

    Quote Originally Posted by RhinoBull
    But you still have to have connection open so use it to execute your sql:

    adoConnection.Exceute strSql
    Here is what I did to get it to work. Thank you for all of your help.

    Code:
    Option Explicit
    Dim strConn As ADODB.Connection
    Dim sql As String
    
    Private Sub cmdClearCache_Click()
        'delete all records in tableX
        Dim objDBaseConn
        Set strConn = New ADODB.Connection
        strConn.ConnectionString = "FILEDSN=mbdb_mb.dsn"
        strConn.Open strConn
        sql = "delete from tableX"
        strConn.Execute sql
        Set objDBaseConn = Nothing
         
    End Sub
    Jim

  6. #6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width