Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Conversion of string to type Double is invalid

Posted on 2009-05-07
5
Medium Priority
?
521 Views
Last Modified: 2012-06-27
Hello Experts,

When I try to build a string based on the datatable and datarow

I am getting an error
"Conversion from string "'" to type 'Double' is not valid."

I am not converting anything to Double I am just building the string

Please help


Dim EroleIDs as string
EroleIDs="" 
For Each dr In dtEroles.Rows
                    If EroleIDs.Length > 0 Then EroleIDs += ","
                    EroleIDs = +"'" + dtEroles.Rows(0)(0).ToString() + "'"
                Next

Open in new window

0
Comment
Question by:rowmark
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 24332713
Hi rowmark,
Try use "&" sign instead of "+" for the string combinations.
eg:
For Each dr In dtEroles.Rows
                    If EroleIDs.Length > 0 Then EroleIDs &= ","
                    EroleIDs &= "'" & dtEroles.Rows(0)(0).ToString() & "'"
                Next
0
 
LVL 3

Expert Comment

by:DreamsTech
ID: 24333076
I wrote a sample code : which worked correctly ,so it will double gets converted into string. The only reason it fails when the vulue you are trying to convert is not a number Or a null value
Dim str As String = ""
 Dim dt As New DataTable
        dt.Columns.Add("test")
        Dim dr As DataRow
        dr = dt.NewRow()
        dr("test") = "DoubleString"
        dt.Rows.Add(dr)
 
For Each dr1 As DataRow In dt.Rows
            str += str + "'" + dr1(0).ToString() + "'"
        Next

Open in new window

0
 
LVL 3

Expert Comment

by:DreamsTech
ID: 24333085
Ingnore my decs ,the only i thing i wanted to convey is ,the above code works fine ,still i in your foreach loop u looping the same row again n again ,the correct syntax wud be

or Each dr In dtEroles.Rows
                    If EroleIDs.Length > 0 Then EroleIDs += ","
                    EroleIDs = +"'" +  dr(0).ToString() + "'"  
                Next

try correcting this and let me know if this helps
0
 
LVL 3

Expert Comment

by:channa_m
ID: 24338360

 Try

dr(0).ToString() instead of   dtEroles.Rows(0)(0).ToString()
0
 
LVL 22

Accepted Solution

by:
prairiedog earned 2000 total points
ID: 24339579
>>>EroleIDs = +"'" + dtEroles.Rows(0)(0).ToString() + "'"
It may be caused by the =+ operation in the above line.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question