473,394 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Pass-through Delete Query

JAMBAI
28
am trying to delete records in the SQL Server from MS Access forms. I got error 3065 cannot execute a select qury, when trying the below code.

Dim qdfPassThrough As DAO.QueryDef
Dim rstPassThrough As DAO.Recordset
Dim strConnect As String
Dim dbCurrent As DAO.Database
Set qdfPassThrough = CurrentDb.CreateQueryDef("")
strConnect = "Driver=SQL SERVER;SERVER = NTSQLSERVER;Database=TEST;UID=mlp;password='';"
qdfPassThrough.Connect = "ODBC;" & strConnect
qdfPassThrough.SQL = "DELETE FROM tempDefTable"
qdfPassThrough.Execute

Please help me

Thanks
Jambai
Apr 16 '07 #1
1 6835
ADezii
8,834 Expert 8TB
am trying to delete records in the SQL Server from MS Access forms. I got error 3065 cannot execute a select qury, when trying the below code.

Dim qdfPassThrough As DAO.QueryDef
Dim rstPassThrough As DAO.Recordset
Dim strConnect As String
Dim dbCurrent As DAO.Database
Set qdfPassThrough = CurrentDb.CreateQueryDef("")
strConnect = "Driver=SQL SERVER;SERVER = NTSQLSERVER;Database=TEST;UID=mlp;password='';"
qdfPassThrough.Connect = "ODBC;" & strConnect
qdfPassThrough.SQL = "DELETE FROM tempDefTable"
qdfPassThrough.Execute

Please help me

Thanks
Jambai
Here is code that I use which dynamically creates a Pass Through Query given a DSN and an ODBC Connection. After creation, the code maximizes the Query Window. Hope this helps:
Expand|Select|Wrap|Line Numbers
  1. Dim qdfPassThrough As DAO.QueryDef, MyDB As Database
  2. Dim strConnect As String
  3.  
  4. If Not IsNull(CurrentDb.QueryDefs("qrySQLPassThroughTwo").SQL) Then    'doesn't exist
  5.   CurrentDb.QueryDefs.Delete "qrySQLPassThroughTwo"
  6. End If
  7.  
  8. Set MyDB = CurrentDb()
  9.  
  10. Set qdfPassThrough = MyDB.CreateQueryDef("qrySQLPassThroughTwo")
  11.  
  12. strConnect = "DSN=SQL Server;Database=Pubs;UID=sa;PWD="
  13. qdfPassThrough.Connect = "ODBC;" & strConnect
  14. qdfPassThrough.SQL = "SELECT * From Authors_2;"
  15. qdfPassThrough.Close
  16.  
  17. Application.RefreshDatabaseWindow
  18.  
  19. DoCmd.OpenQuery "qrySQLPassThroughTwo", acViewNormal, acReadOnly
  20. DoCmd.Maximize
Apr 17 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
4
by: z_learning_tester | last post by:
I'm reading the MS press C# book and there seems to be a contradiction. Please tell me which one is correct, 1 or 2. Thanks! Jeff 1. First it gives the code below saying that it prints 0 then...
5
by: David++ | last post by:
Hi folks, I would be interested to hear peoples views on whether or not 'pass by reference' is allowed when using a Web Service method. The thing that troubles me about pass-by-reference into...
14
by: Abhi | last post by:
I wrote a function foo(int arr) and its prototype is declared as foo(int arr); I modify the values of the array in the function and the values are getting modified in the main array which is...
3
by: QQ | last post by:
I have one integer array int A; I need to pass this array into a function and evaluate this array in this function how should I pass? Is it fine? void test(int *a)
4
by: kinaxx | last post by:
Hello, now I'm learning progamming language in university. but i have some question. in textbook. says there are four passing Mechanism 1) pass by value (inother words : call by value) 2)...
10
by: Robert Dailey | last post by:
Hi, I noticed in Python all function parameters seem to be passed by reference. This means that when I modify the value of a variable of a function, the value of the variable externally from the...
6
by: lisp9000 | last post by:
I've read that C allows two ways to pass information between functions: o Pass by Value o Pass by Reference I was talking to some C programmers and they told me there is no such thing as...
15
by: ramif | last post by:
Does call by reference principle apply to pointers?? Is there a way to pass pointers (by reference) to functions? Here is my code: #include <stdio.h> #include <stdlib.h>
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.