16,016,770 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Scott A Parker (Top 4 by date)
Scott A Parker
4-Jun-13 10:36am
View
Deleted
No need to serialize the settings... Just save the settings as they would appear in code and have your application substitute them in the place of the code settings.
public Font AdjustFontSettings()
{
// Code to read settings here
string fntFam = "Arial"; // <-- Represented by string stored in settings file
float fntSize = 15; // <-- Represented by string stored in settings file
string fntStyle = "Regular"; // <-- Represented by string stored in settings file
Font myFont = null;
switch (fntStyle)
{
case "Bold":
myFont = new Font(fntFam, fntSize, FontStyle.Bold);
break;
case "Italic":
myFont = new Font(fntFam, fntSize, FontStyle.Italic);
break;
case "Regular":
myFont = new Font(fntFam, fntSize, FontStyle.Regular);
break;
case "Strikeout":
myFont = new Font(fntFam, fntSize, FontStyle.Strikeout);
break;
case "Underline":
myFont = new Font(fntFam, fntSize, FontStyle.Underline);
break;
}
return myFont;
}
Scott A Parker
3-May-13 17:42pm
View
Here is some code from a personal project. I use MySql but the procedures should be fairly consistent across most SQL database systems or should be easy to modify.
<pre lang="c#">//********************************************************************************
//Convert image for storage in database
//********************************************************************************
MemoryStream stream = new MemoryStream();
picID.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] pic_data = stream.ToArray();
string q = "Update customer Set Customer_FirstN='" + FName + "', Customer_MiddleN='" + MName + "', Customer_LastN='" + LName +
"', Customer_Add1='" + Add1 + "', Customer_Add2='" + Add2 + "', Customer_City='" + City + "', Customer_State='" + State +
"', Customer_Zip='" + Zip + "', Customer_Phone='" + Phone + "', Customer_Cell='" + Cell + "', Customer_Sex='" + Sex +
"', Customer_Race='" + Race + "', Customer_Height='" + Height + "', Customer_Weight='" + Weight + "', Customer_Eyes='" + Eyes +
"', Customer_Hair='" + Hair + "', Customer_Flag='" + Flag + "', Customer_Notes='" + Note + "', Customer_ID_Num='" + IdNum +
"', Customer_ID_Issue_State='" + IdState + "', Customer_ID_Type='" + IdType + "', Customer_BDate='" + DOB + "', Customer_ID_Exp='" + IdExp +
"', Customer_ID_Issue='" + IdIssue + "', Customer_Class='" + Class + "', Customer_Image=@Pic Where Customer_ID_Num='" + txtIDNum.Text + "'";
string Param = "@Pic";
public void dbWrite(string Query, string Param, Array pic_data )
{
MySqlConnection con = new MySqlConnection(conStr);
MySqlCommand cmd = new MySqlCommand(Query, con);
if (Param != null)
{
cmd.Parameters.AddWithValue(Param, pic_data);
}
con.Open();
cmd.ExecuteNonQuery();
}
//Reading image from database
//*************************************************************************
public MemoryStream dbReadImage(string Query, string Image)
{
MemoryStream stream;
MySqlConnection con = new MySqlConnection(conStr);
MySqlCommand cmd = new MySqlCommand(Query, con);
MySqlDataAdapter dp = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet("MyImages");
byte[] MyData = new byte[0];
dp.Fill(ds, "MyImages");
DataRow myRow;
myRow = ds.Tables["MyImages"].Rows[0];
MyData = (byte[])myRow[Image];
return stream = new MemoryStream(MyData);
}</pre>
Scott A Parker
3-May-13 17:25pm
View
If you are logging into Active Directory then the "Environment.UserName" will be your logged in user ID as well as your userid for the computer. If you are interested in any possible user that may be or may have been logged in you will need to look in WMI.
Scott A Parker
3-May-13 16:52pm
View
You might want to create an XML file and use it for saving your settings.