help please, cast into double stuff

conelbeano

New member
Joined
Oct 8, 2004
Messages
2
my code keeps generating an error that goes like this:

Cast from string "select inventory_category from i" to type Double is not valid

my code loks like this :
Code:
RS.Open("Select * from tblinventorycategories where device <> " + "" + "", CN, 1, 2)
        RSS.Open("Select * from inventorycategory", CNN, 1, 2)
        Dim a, b As Integer
        Do While RS.EOF() = False
            RSS.AddNew()
            rr.Open("select function_id from function where function = " + RS.Fields("functionid").Value + "", CNN, 1, 2)
            a = rr.Fields("function_id").Value
            rr.Close()
            rr.Open("select device_category_id from devicecategory where device_category = " + RS.Fields("devicecategory").Value + "", CNN, 1, 2)
            b = rr.Fields("device_category_id").Value
            rr.Close()


 -----> RRSS.Open("select inventory_category from inventorycategory         
            where function_id = " + a + " and devicecategory = " + b + "",     
            CNN, 1, 2)
            

RSS.Fields("category_id").Value = RRSS.Fields("inventory_category").Value
            RRSS.Close()
            RSS.Fields("devicename").Value = RS.Fields("device").Value
            RSS.Update()
            RS.MoveNext()
        Loop

        RS.Close()
        RSS.Close()

the connections were made in other lines, so i know theyre not there error happens at the arrow. if you have help, or suggestions, please help me as i am stuck
 
Last edited by a moderator:
in the line
Code:
RRSS.Open("select inventory_category from inventorycategory
where function_id = " + a + " and devicecategory = " + b + "",
CNN, 1, 2)
you are trying to add a string to the variable a - presumably a is a double, you should use & to concatenate and also convert the double to a string before concatenating.
try something like
Code:
RRSS.Open("select inventory_category from inventorycategory
where function_id = " & a.ToString() & " and devicecategory = "  & b.ToString() & "",
CNN, 1, 2)
above code assumes b is also a numeric type.
 
im not trying to add anything to anything, im searching a database using two criteria, and it wont do it, and give me that error, i have tried everything that i know of, and it works in other areas of the programming, so i dont know why it doesnt work here, and i didnt know if anyone had any ideas.
 
Did you try the code I posted? Regardless of what you think you are doing the + symbol in your code will try to add the operands together, use the & to concatenate string values together.
 
Back
Top