conelbeano Posted October 8, 2004 Posted October 8, 2004 (edited) 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 : 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 they're not there error happens at the arrow. if you have help, or suggestions, please help me as i am stuck Edited February 19, 2007 by PlausiblyDamp Quote
Administrators PlausiblyDamp Posted October 8, 2004 Administrators Posted October 8, 2004 in the line 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 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
conelbeano Posted October 11, 2004 Author Posted October 11, 2004 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. Quote
Administrators PlausiblyDamp Posted October 12, 2004 Administrators Posted October 12, 2004 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.