TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Net Eth
NA
1
1.8k
How to insert background color from a variable
Jan 16 2013 5:48 AM
Hello:
I am working in visual studio (C#) and i wanted to fill the back groud color of my forms to be filled from a variable which is stored in a database. the datatype of the variable is nvarchar. i wrote the following code but it does't seem to work
string
connString =
"Server=.\\SQLExpress;Database=MyDB;Trusted_Connection=Yes;"
;
SqlConnection
con =
new
SqlConnection
(connString);
con.Open();
string
backgroundcolor;
SqlDataReader
rdrI =
null
;
SqlCommand
cmdI =
null
;
string
CommandText =
"SELECT * FROM LOOKUP WHERE ([key] = 'Backgroundcolor')"
;
cmdI =
new
SqlCommand
(CommandText, con);
rdrI = cmdI.ExecuteReader();
while
(rdrI.Read())
{
MessageBox
.Show(rdrI[
"Value"
].ToString());
backgroundcolor = rdrI[
"Value"
].ToString();
form.BackgroundImage =
null
;
form.BackColor =
Color
.FromName(backgroundcolor);
}
Reply
Answers (
2
)
c#
how to create popup property area calculater