Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by PlausiblyDamp
  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...