[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
Re: running a delete query with a dsn
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.
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
Re: running a delete query with a dsn
But you still have to have connection open so use it to execute your sql:
adoConnection.Exceute strSql
[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
Re: [RESOLVED] - running a delete query with a dsn
Yea, that's all needed. :thumb: