|
-
Sep 7th, 2004, 06:38 AM
#1
Thread Starter
Addicted Member
Help with Syntax on db delete using ID (resolved)
Hi,
Can anyone please help me to understand the conversion of this syntax used in the following two scenarios:
When execute, I get the following error message from the 1st set of code:
"No value given for one or more required parameters."
Thanks,
Phillip
Code:
'This code does NOT work
dim test as string
test = LTrim(tmpSTR(UBound(tmpSTR))) ' test = 1
Set MyRecSet = MyConn.Execute("DELETE * FROM table1 WHERE ID =" & test)
Code:
'This code does work
'dim test as string
'test = LTrim(tmpSTR(UBound(tmpSTR))) ' test = 1
Set MyRecSet = MyConn.Execute("DELETE * FROM table1 WHERE ID =" & "1")
Last edited by Iat; Sep 8th, 2004 at 03:43 PM.
-
Sep 7th, 2004, 10:11 AM
#2
Hyperactive Member
The reason behind this is because you are getting NO value on this code since the array cell does not exist:
VB Code:
test = LTrim(tmpSTR(UBound(tmpSTR)))
If for example your tmpSTR array has the ff. information:
Code:
+---+---------+
| 0 | APPLE |
| 1 | BANANA |
| 2 | ORANGE |
| 3 | GRAPES |
+---+---------+
Your UBound(tempSTR) is equal to 4 since you have 4 data in your array. However, when addressing each array cell, you start with 0 and end with 3.
tmpSTR(0) = APPLE
tmpSTR(1) = BANANA
tmpSTR(2) = ORANGE
tmpSTR(3) = GRAPES
Your tmpSTR(UBound(tmpSTR)) is actually tmpSTR(4) which doesn't exist. hence you get the error.
-
Sep 7th, 2004, 12:18 PM
#3
Thread Starter
Addicted Member
I am sorry I didn't explain that part. the split() function was declared public and used throughout the application. I changed the code this way to better explain my dilemma. Within my application, I can query and add records to the mdb without any problems.
Code:
'This does NOT work
dim test as string
test = "1"
Set MyRecSet = MyConn.Execute("DELETE * FROM table1 WHERE ID = " & test)
Code:
'This does work
'dim test as string
'test = "1"
Set MyRecSet = MyConn.Execute("DELETE * FROM table1 WHERE ID = " & "1")
-
Sep 8th, 2004, 01:47 PM
#4
Hyperactive Member
Do you get the same error message as with your first post on this revised code?
VB Code:
'This does NOT work
dim test as string
test = "1"
Set MyRecSet = MyConn.Execute("DELETE * FROM table1 WHERE ID = " & test)
-
Sep 8th, 2004, 03:43 PM
#5
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|