Solved

Convert string to system.drawing.color

Posted on 2006-07-15
2
2,278 Views
Last Modified: 2012-06-27
I am trying to change the color of a control from a srting value in a sql database.
The test value in the field is "black" as a string. I can not seem to convert the string to system.drawing.color.
Below is my code

Dim labelcolor As System.Drawing.Color

           Try
            Dim strSQL As String = "Select * from startup"

            Dim myConnection As New SqlConnection(connectionstring)
            Dim sqlCmd As New SqlCommand(strSQL)
            Dim sqlReader As SqlDataReader
            sqlCmd.Connection = myConnection
            myConnection.Open()
            sqlReader = sqlCmd.ExecuteReader

            If (sqlReader.Read()) Then

                labelcolor = ctype (sqlReader("headerarea2",System.Drawing.Color))
                HeaderLabel.BackColor = labelcolor
               

                            End If
        Catch exp As Exception
            lblerror.Text = exp.ToString
        End Try
0
Comment
Question by:edshoro
[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
  • 2
2 Comments
 
LVL 9

Expert Comment

by:zaghaghi
ID: 17114515
use
System.Drawing.Color.FromName function
0
 
LVL 9

Accepted Solution

by:
zaghaghi earned 250 total points
ID: 17114518
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

691 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