|
-
Jun 17th, 2004, 10:58 AM
#1
Thread Starter
Member
[RESOLVED] simple datatable select statment
Ok this is overly simple, but driving me crazy. Any thoughts are much appreciated.
Dim q As String
dim ro as datarow
'tbliptval is a public datatable
q = "CID = " & Process_cid & " And Name = '" & varname & "'"
Try
ro = tblIptVal.Select(msg)(0)
Catch e As Exception
MsgBox(e.ToString)
End Try
The query q should return one record, and does when i manually enter the sql.
Any thoughts? ahhhhhhhhh!
Last edited by SeaCapnJ; Jun 17th, 2004 at 03:13 PM.
-
Jun 17th, 2004, 11:28 AM
#2
Frenzied Member
Not sure what you're trying to do. If q is supposed to be part of your SQL, where do you add it to anything? In the posted code it doesn't serve a purpose.
-
Jun 17th, 2004, 11:34 AM
#3
Thread Starter
Member
Does this explain it better, I assigned the string to q to help in debugging. Any thoughts? thanks for the response.
VB Code:
Try
ro = tblIptVal.Select("CID = " & Process_cid & " And Name = '" & varname & "'")(0)
process_UDID = ro("UDID")
If Not ro.IsNull("UDID") Then
processSourceID = ro("PSID")
End If
catch e as exception
MsgBox(e.ToString)
End Try
-
Jun 17th, 2004, 11:47 AM
#4
Frenzied Member
Doesn't Select return an Array of DataRows, not a single DataRow?
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Jun 17th, 2004, 12:14 PM
#5
Fanatic Member
Originally posted by SeanGrebey
Doesn't Select return an Array of DataRows, not a single DataRow?
It does indeed.
-
Jun 17th, 2004, 12:17 PM
#6
Thread Starter
Member
Yah, it does.
That's why I am grabbing the table at index 0.
ro = tblIptVal.Select(msg)(0)
the error message it gives is something like:
"filter expression "0" does not evaluate to a boolean term." So maybe that is where im going wrong.
-
Jun 17th, 2004, 12:20 PM
#7
Fanatic Member
Originally posted by SeaCapnJ
Yah, it does.
That's why I am grabbing the row at index 0.
But you've declared "ro" as a datarow object - not an array of objects of type datarow.
Code:
Dim ro() as DataRow
-
Jun 17th, 2004, 12:24 PM
#8
Thread Starter
Member
I guess I didnt edit that response quick enough. 
but ill play with it, maybe it is the indexing ?
-
Jun 17th, 2004, 12:29 PM
#9
Thread Starter
Member
Dim r As DataRow()
r = tblIptVal.Select(msg)
Tried that, Got the same error message about indexing at 0.
Man I have written 100's of these, what am I doing wrong here? grr!
-
Jun 17th, 2004, 12:34 PM
#10
Fanatic Member
Post your current code so we're not talking past one another.
-
Jun 17th, 2004, 12:52 PM
#11
Thread Starter
Member
I get an index out of range message, which tends leads me to believe that the query is resulting in null. However, when I manually enter the query, I get a record.
VB Code:
Dim ro As DataRow()
Dim q As String
q = "CID = " & Process_cid & " And Name = '" & varname & "'"
Try
MsgBox(q)
ro = tblIptVal.Select(q)
process_UDID = ro(0)("udid")
Catch e As Exception
MsgBox(e.ToString)
End Try
-
Jun 17th, 2004, 01:10 PM
#12
Thread Starter
Member
Well the problem is with varname, for some reason when I type it in, its not exactly like what I see. I do not have the answer to what is wrong, but I do not understand why the string that I see and the string that I type are not the same.
-
Jun 17th, 2004, 01:11 PM
#13
Fanatic Member
-
Jun 17th, 2004, 02:25 PM
#14
Frenzied Member
varname doesn't have a single quote in it does it?
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Jun 17th, 2004, 03:12 PM
#15
Thread Starter
Member
Always the simple solution. Why could I find the record I was looking for? Because I was deleting that record in a forum i wrote months ago. Bah!
Thanks so much for the help guys.
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
|