473,569 Members | 2,481 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

query run successfully in sql*plus but return 0 records affected in vb6

5 New Member
I've did a program using vb6 to connect to oracle9i, i can establish the connection, the problem is when i execute the query in oracle sql*plus, it can execute successfully, but when run in vb application, the records affected return 0, it do nothing for this query, any setting need to be done?
because this query insert and select to/from different database, i've created a database link for these 2 database, everything work find in oracle sql*plus.

thanks for help..

Expand|Select|Wrap|Line Numbers
  1. db.Open "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;USER ID=max;PASSWORD=max;Data Source=oracledb"
  2.  
  3. sSQL = "INSERT INTO FWDINVOICE_DET@ORACLEAR (COMPANYCODE,BRANCHCODE,INVOICENO,JOBNO,CHARGECODE)" & _
  4. " (SELECT FWDINVOICE_DET.COMPANYCODE,FWDINVOICE_DET.BRANCHCODE," & _
  5. " FWDINVOICE_DET.InvoiceNo,FWDINVOICE_DET.JobNo,FWDINVOICE_DET.ChargeCode" & _
  6. " FROM FWDINVOICE_DET@ORACLEDB,FWDINVOICE_HD@ORACLEDB" & _
  7. " Where FWDINVOICE_HD.CompanyCode = FWDINVOICE_DET.CompanyCode" & _
  8. " AND FWDINVOICE_HD.BRANCHCODE=FWDINVOICE_DET.BRANCHCODE" & _
  9. " AND FWDINVOICE_HD.INVOICENO=FWDINVOICE_DET.INVOICENO" & _
  10. " AND ( FWDINVOICE_HD.CANCEL= 'Y' OR FWDINVOICE_HD.APPROVED='Y') AND "
  11. sSQL = sSQL & oLib.SQLRangeDate("FWDINVOICE_HD.InvoiceDate", Format(dtDateFrom, "dd-MMM-yyyy"), Format(dtDateTo, "dd-MMM-yyyy"))
  12. sSQL = sSQL & ")"
  13.  
  14. sSQL = UCase(sSQL)
  15. db.Execute sSQL
  16.  
Nov 29 '06 #1
9 2504
Killer42
8,435 Recognized Expert Expert
I don't know the cause of your problem, but if those dates are going into date/time fields in Access, I think you need to put them in m/d/yyyy format rather than dd-mm-yyyy, and put hashes (#) around them.

You might also need a semicolon on the end of the query.
Nov 29 '06 #2
skyloon
5 New Member
i've tried using to_char, to_date, trunc, the problem still can't solve..
may i know what is the correct date format?
Nov 29 '06 #3
Killer42
8,435 Recognized Expert Expert
i've tried using to_char, to_date, trunc, the problem still can't solve..
may i know what is the correct date format?
Generally, in SQL (for Access, at least) the format for a date is American format with hashes around it. Taking today as an example, that would be #11/30/2006#.

Can you tell us what oLib.SQLRangeDa te() does? Or better still, post a copy of what's in sSQL immediately before issuing the Execute.
Nov 29 '06 #4
skyloon
5 New Member
here is the result from immediate window.
run this query in sql*plus, it returns result, but it returns 0 records affected in when i try to debug it..

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO FWDINVOICE_DET@ORACLEAR (COMPANYCODE,BRANCHCODE,INVOICENO,JOBNO,CHARGECODE) 
  2. (SELECT FWDINVOICE_DET.COMPANYCODE,FWDINVOICE_DET.BRANCHCODE, FWDINVOICE_DET.INVOICENO,
  3.     FWDINVOICE_DET.JOBNO,FWDINVOICE_DET.CHARGECODE 
  4. FROM FWDINVOICE_DET@ORACLEDB,FWDINVOICE_HD@ORACLEDB 
  5. WHERE FWDINVOICE_HD.COMPANYCODE = FWDINVOICE_DET.COMPANYCODE 
  6.     AND FWDINVOICE_HD.BRANCHCODE=FWDINVOICE_DET.BRANCHCODE 
  7.     AND FWDINVOICE_HD.INVOICENO=FWDINVOICE_DET.INVOICENO 
  8.     AND ( FWDINVOICE_HD.CANCEL= 'Y' OR FWDINVOICE_HD.APPROVED='Y') 
  9.     AND (FWDINVOICE_HD.INVOICEDATE BETWEEN '30-NOV-2003' AND '30-NOV-2006'))
  10.  
Nov 30 '06 #5
skyloon
5 New Member
here is the coding for your reference

coding in VB
Expand|Select|Wrap|Line Numbers
  1. dtDateFrom = dtpDate1.Value
  2. dtDateTo = dtpDate2.Value
  3. Set db = New ADODB.Connection
  4. db.Open "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;USER ID=max;PASSWORD=max;Data Source=oracledb"
  5.  
  6. sSQL = "INSERT INTO FWDINVOICE_DET@ORACLEAR (COMPANYCODE,BRANCHCODE,INVOICENO,JOBNO,CHARGECODE)" & _
  7.     " (SELECT FWDINVOICE_DET.COMPANYCODE,FWDINVOICE_DET.BRANCHCODE," & _
  8.         " FWDINVOICE_DET.InvoiceNo,FWDINVOICE_DET.JobNo,FWDINVOICE_DET.ChargeCode" & _
  9.     " FROM FWDINVOICE_DET@ORACLEDB,FWDINVOICE_HD@ORACLEDB" & _
  10.     " Where FWDINVOICE_HD.CompanyCode = FWDINVOICE_DET.CompanyCode" & _
  11.         " AND FWDINVOICE_HD.BRANCHCODE=FWDINVOICE_DET.BRANCHCODE" & _
  12.         " AND FWDINVOICE_HD.INVOICENO=FWDINVOICE_DET.INVOICENO" & _
  13.         " AND ( FWDINVOICE_HD.CANCEL= 'Y' OR FWDINVOICE_HD.APPROVED='Y') AND "
  14. sSQL = sSQL & oLib.SQLRangeDate("FWDINVOICE_HD.InvoiceDate", Format(dtDateFrom, "dd-mmm-yyyy"), Format(dtDateTo, "dd-Mmm-yyyy"))
  15. sSQL = sSQL & ")"
  16.  
  17. sSQL = UCase(sSQL)
  18. Dim i As Integer
  19. db.Execute sSQL, i
  20. db.CommitTrans
  21.  
  22. Debug.Print sSQL
  23. Debug.Print "records return: "; i
  24. Debug.Print "Errors: "; Error
  25. Debug.Print "DB Error Count: "; db.Errors.Count
  26. Debug.Print "Connection Mode: "; db.Mode
  27. Stop
  28.  
Result from immediate window
INSERT INTO FWDINVOICE_DET@ ORACLEAR (COMPANYCODE,BR ANCHCODE,INVOIC ENO,JOBNO,CHARG ECODE) (SELECT FWDINVOICE_DET. COMPANYCODE,FWD INVOICE_DET.BRA NCHCODE, FWDINVOICE_DET. INVOICENO,FWDIN VOICE_DET.JOBNO ,FWDINVOICE_DET .CHARGECODE FROM FWDINVOICE_DET@ ORACLEDB,FWDINV OICE_HD@ORACLED B WHERE FWDINVOICE_HD.C OMPANYCODE = FWDINVOICE_DET. COMPANYCODE AND FWDINVOICE_HD.B RANCHCODE=FWDIN VOICE_DET.BRANC HCODE AND FWDINVOICE_HD.I NVOICENO=FWDINV OICE_DET.INVOIC ENO AND ( FWDINVOICE_HD.C ANCEL= 'Y' OR FWDINVOICE_HD.A PPROVED='Y') AND (FWDINVOICE_HD. INVOICEDATE BETWEEN '30-NOV-2003' AND '30-NOV-2006'))
records return: 0
Errors:
DB Error Count: 0
Connection Mode: 0
Nov 30 '06 #6
Killer42
8,435 Recognized Expert Expert
Ok, for starters I think you might get a better response to this question in the Access forum.

Now, given the SQL string you posted, I can see a couple of things which look a bit odd. Whether they will cause problems, I don't know. You need to keep in mind that I'm a VB6 developer and not an Access expert. With luck, someone more knowledgeable in this area might pick up the thread.

Comments:
  • Perhaps Access doesn't like "@" in a field name?
  • Date formats do not look like Access dates, as mentioned previously.
Here's a modified version. Let me know whether it's any help. Sorry about the layout - I just chopped up the lines so I could more easily identify the pieces involved.
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO
  2.   FWDINVOICE_DET@ORACLEAR
  3.     (COMPANYCODE, BRANCHCODE, INVOICENO, JOBNO, CHARGECODE)
  4.     (SELECT
  5.        FWDINVOICE_DET.COMPANYCODE,
  6.        FWDINVOICE_DET.BRANCHCO DE,
  7.        FWDINVOICE_DET.INVOICENO,
  8.        FWDINVOICE_DET.JOBNO,
  9.        FWDINVOICE_DET.CHARGECODE
  10.      FROM
  11.        FWDINVOICE_DET@ORACLEDB,
  12.        FWDINVOICE_HD@ORACLEDB
  13.      WHERE
  14.        FWDINVOICE_HD.COMPANYCODE  = FWDINVOICE_DET.COMPANYCODE
  15.      AND FWDINVOICE_HD.BRANCHCODE = FWDINVOICE_DET.BRANCHCODE
  16.      AND FWDINVOICE_HD.INVOICENO  = FWDINVOICE_DET.INVOICENO
  17.      AND (FWDINVOICE_HD.CANCEL= 'Y' OR FWDINVOICE_HD.APPROVED = 'Y')
  18.      AND (FWDINVOICE_HD.INVOICEDATE BETWEEN #11/30/2003# AND #11/30/2006#)
  19.    )
Nov 30 '06 #7
Killer42
8,435 Recognized Expert Expert
here is the coding for your reference ...
Expand|Select|Wrap|Line Numbers
  1.  ...
  2. db.Execute sSQL, i
  3. db.CommitTrans
  4.  ...
I'm not saying this is a problem, just curious - did you ever do a BeginTrans?
Nov 30 '06 #8
skyloon
5 New Member
this query is not for access, is for oracle..
i've mentioned it in the first thread..

I included the db.CommitTrans as well, just forgot to paste it here..sorry man..
Nov 30 '06 #9
Killer42
8,435 Recognized Expert Expert
this query is not for access, is for oracle..
i've mentioned it in the first thread..
Sorry, I'm getting it mixed up with other threads. (By the way, it was the first post, or message. The "thread" refers to the whole conversation.)

However, you'll find much more SQL expertise in the Access thread. If the problem is the database conenction then you might find some help here - for instance, willakawill seems to know this area quite well.

I can't think of any way to help further, sorry. I'm surprised it has been so quiet - normally a couple of people would have jumped into the conversation by now.

I included the db.CommitTrans as well, just forgot to paste it here..sorry man..
You mean the BeginTrans, I hope. :)
Nov 30 '06 #10

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

Similar topics

1
3810
by: Ruben Schoenefeld | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi - after I got sql*plus to work on my Linux box and I recompiled PHP 5 to include the oracle instant client, I run into a weird problem: I get 'ORA-01017: invalid username/password; logon denied' when using the same combination of username/password and Oracle instance that works in...
3
15042
by: valexena | last post by:
In order to set SQL*PLUS session so that NLS_DATE_FORMAT information is altered in a specific way every time I log into Oracle which method would be used? -- Posted via http://dbforums.com
0
2010
by: GP | last post by:
Consider the following: (extracted from a .bat) sqlplus toto/titi ^ @%pdl%\islqz033 ^ '1 ' ^ 'aaa' ^ ' ' ^ 'zzz' ^ ....
3
20053
by: Peter | last post by:
Has anyone seen this before? I start SQL*Plus, and login by typing sqlplus Quantum/Password@BPrd I type: select '&1' from dual; it responds
1
4308
by: Miori | last post by:
Dear all, Server machine running Oracle Database Server on Linux and a Client machine running Oracle Client on WIndows XP. HOw it is possible to shut down/start up the Oracle database on the server from SQL*Plus of the client. I know it can be done from SQL*Plus of the server but the point is that I want to do it from SQL*Plus of the...
2
4124
by: Ant | last post by:
Hi, I have an SQL assignment to do and at my school we use SQL *Plus there however I don't have Oracle at home, where I would like to do the work ,so I was wondering whats the easiest way to get an SQL environment up so I can code in that then just paste it into SQL *Plus later. I don't really want to install Oracle on my home pc and I...
1
1883
by: gomathy | last post by:
Hello All! I am newbie to oracle. As a first step, i tried to install oracle sql*plus instant client on my machine to start working with sql simple commands like "table creation etc". This installation was successfull. But when i tried to access from command line, i was prompted to enter username and password. I have no clue to what should...
0
2507
DTV12345
by: DTV12345 | last post by:
Greetings! This is an excerpt from the Oracle documentation:"...ORACLE SQL*Plus BREAK command creates a subset of records and add space and/or summary lines after each subset. The column you specify in a BREAK command is called a break column which suppresses duplicate values. For example SQL> BREAK ON DEPTNO SKIP 1 // To insert...
9
3326
by: ghssal | last post by:
HI I am using ORACLE forms and trying to insert a new order, by enter the customer_ID and i will get the latest order för this customer and save the new order with new order_date. I use this Trigger select ..... from customer_order, ( select customer_ID AS B, MAX(order_date) AS S from customer_order
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7678
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.