Article ID: 180348
Article Last Modified on 1/22/2007
Function PassThruUpdate(strUpdateData As String)
Dim db As Database
Dim qd As QueryDef
Dim strSQLString As String
On Error GoTo Err_PassThruUpdate
Set db = CurrentDb
Set qd = db.CreateQueryDef("")
' Modify the connect string in the following line
' to reflect the ODBC data source you are using.
qd.Connect = "ODBC;DSN=sqltest;UID=<username>;PWD=<strong password>;DATABASE=pubs"
strSQLString = "UPDATE tbltoSQL SET StringTest = '"
strSQLString = strSQLString & strUpdateData
strSQLString = strSQLString & "' WHERE id = 'a'"
qd.ReturnsRecords = False
qd.SQL = strSQLString
qd.Execute dbFailOnError
db.Close
Exit_PassThruUpdate:
Exit Function
Err_PassThruUpdate:
MsgBox CStr(Err) & " " & Err.Description
Resume Exit_PassThruUpdate
End Function
Table: tblToSQL
----------------------
Field Name: ID
Data Type: Text
Field Size: 2
Field Name: StringTest
Data Type: Text
Field Size: 100
Table Properties: tblToSQL
--------------------------
PrimaryKey: ID
ID FullName
-- --------
a aaa
b bbb
Function TestExecute(intUpdateLength As Integer)
Dim db As Database
Dim strSQLString As String
Dim strUpdateString As String
strUpdateString = String(intUpdateLength, "X")
strSQLString = "UPDATE dbo_tblToSQL SET StringTest = '" & _
strUpdateString
strSQLString = strSQLString & "' WHERE id = 'a';"
Set db = CurrentDb
db.Execute strSQLString, dbFailOnError
db.Close
End Function
Additional query words: Watson
Keywords: kbbug kbpending KB180348