|
Read the following from the CP daily news about C# nullable reference types.
Introducing Nullable Reference Types in C# | .NET Blog[^]
I have got to say that this is one of the best new language features that I have seen in a long time. Last I can recall specifically that I liked was generics in Java - like them but didn't care much for the hacked implementation required to make them 'fit' in java.
But, at least based on this description for the feature above in C#, I like the idea and how they are going to implement it.
|
|
|
|
|
Since we were talking about patterns in another thread, I assume you're familiar with the Null object pattern - Wikipedia[^]?
Funny article BTW; I did not expect that a "null reference" needed to be implemented as a feature.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I believe I looked at that long ago.
C++ api libraries (standard) have a similar class called auto_ptr. I tried it and didn't find it particularly useful. Probably due to the complexity of usage in some cases. Perhaps the same reason that it is now deprecate in C++ (but to be clear I cannot remember why I didn't like it.)
|
|
|
|
|
I would not call the example C# code complex.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: I would not call the example C# code complex.
Ok, but not sure how that is relevant to what I said about auto_ptr (which is not only used for that.)
|
|
|
|
|
It's not, just like talking about C++ in a C# forum isn't
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I am trying to create a C# widows form application that allows people to attend a group and sign up to one of the days they have. I would like the users to be able to sign in inputting their name, organisation, group and then using an automated time, to sign out. This data should then be copied to a database or file. they should then sign out later choosing their name from a drop down menu and again clicking a box so to get another automated time in which they will be able to sign out. The timein and timeout will be used to create a retention time in which the admin can access a page that displays this in a bar chart. There should be an option to register users to a group or create a group on the admin page.
|
|
|
|
|
..and your question is...?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
And?
What have you tried?
Where are you stuck?
What help do you need?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have tried searching for tutorials and need help being pointed in the right direction.
I am stuck with trying to get the local database to accept data and ensuring my SQL commands are safe. I would also like help for what you would do if creating this application.
|
|
|
|
|
That doesn't tell us what you have tried: we have no idea what stage you have got to.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Please help. How to put two columns in a combo box (list Box, text box:mad. I work with VS2015, c# and MySql 5.7.
Attached part of the code.
private void comboBox1_Click (object sender, EventArgs e)
{
MySqlConnection conn;
myConnectionString = pwput;
conn = new MySql.Data.MySqlClient.MySqlConnection ();
conn.ConnectionString = myConnectionString;
try
{
conn.Open ();
}
catch (MySqlException ex)
{
switch (ex.Number)
{
case 0:
MessageBox.Show ("DO NOT SUCCE TO CONNECT ON SERVER, CLOSE PROGRAM TO TAKE A REPLY");
Close ();
break;
case 1042:
MessageBox.Show ("NOT ACTIVE SERVER, SUBSCRIBE SERVER PA REPEAT CONNECTING");
Close ();
break;
}
conn.Close ();
}
if (conn.State! = ConnectionState.Open)
{
MessageBox.Show ("DO NOT SUCCE TO CONNECT ON SERVER \ r \ n CLOSE PROGRAM TO TAKE READY \ r \ n");
}
else
{
AutoCompleteStringCollection kontoopis = new AutoCompleteStringCollection ();
string wnadidok = "SELECT idkonto, FROM account name";
loadingData = false;
DataTable dtkon = new DataTable ();
dtkon.Columns.Add ();
dtkon.Columns.Add ();
MySqlDataAdapter mdkon = new MySqlDataAdapter (wnadidok, conn);
mdkon.Fill (dtkon);
loadingData = true;
comboBox1.DataSource = dtkon;
// which field is shown in the table below
comboBox1.DisplayMember = "idkonto";
comboBox1.ValueMember = "idkonto";
comboBox1.DisplayMember = "title";
comboBox1.ValueMember = "title";
comboBox1.SelectedIndex = -1;
comboBox1.Text = "";
loadingData = false;
}
conn.Close ();
}
Thank you
|
|
|
|
|
|
|
your select query doesnt contans "title " but you have mapped the title to value member
the below lines repeating twice, however the compiler will takes only the latest assigned values
comboBox1.DisplayMember = "idkonto";
comboBox1.ValueMember = "idkonto";
comboBox1.DisplayMember = "title";
comboBox1.ValueMember = "title";
try concatenating the two columns in the select query as
string wnadidok = "SELECT idkonto + ' ' + title as combinedCol , title FROM [account name]";
and change the DisplayMember and ValueMember as
comboBox1.DisplayMember = "combinedCol";
comboBox1.ValueMember = "title";
|
|
|
|
|
|
welcome
|
|
|
|
|
I know very little about AD. I found this article but it's old.
We have a device that requires the user to log in. Currently, the usernames/passwords are stored in a table in the database on the device. In the table are also roles such as "Operator" and "Supervisor", and an Active checkbox.
We now have a requirement that if AD is configured/enabled, then use that to validate the user. This opens up some questions.
1) How can I tell in C# if AD is configured/enabled?
2) Is it possible using AD to store and retrieve the roles I mentioned as well as the Active checkbox?
The goal would be to not store this info locally on a device but to have validate and identify the user and device related information from outside the device.
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
It will probably be easier to use the System.DirectoryServices.AccountManagement[^] namespace. You can use Active Directory groups to represent the roles.
public static bool ValidateCredentials(string userName, string password)
{
using (var context = new PrincipalContext(ContextType.Domain))
{
return context.ValidateCredentials(userName, password);
}
}
public static bool IsUserActive(string userName)
{
using (var context = new PrincipalContext(ContextType.Domain))
{
var user = UserPrincipal.FindByIdentity(context, userName);
return user != null && user.Enabled == true;
}
}
public static bool IsUserInRole(string userName, string roleName)
{
using (var context = new PrincipalContext(ContextType.Domain))
{
var user = UserPrincipal.FindByIdentity(context, userName);
var group = GroupPrincipal.FindByIdentity(context, roleName);
return user != null && group != null && user.IsMemberOf(group);
}
}
To detect whether the computer is joined to a domain, you'll need to P/Invoke the NetGetJoinInformation[^] function:
.net - How to detect if machine is joined to domain (in C#)? - Stack Overflow[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
When you refer to Role, what exactly is that? Is a Role in the sense you're referring to something that can be defined by the System Admin?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Role is your concept, AD works with GROUPS and a user is a member of 1 or more groups, a heavy security requirement can be a nightmare. We had to get creative around the name of the groups to support department and role. Typically
Finance_Op = finance operations
Finance_RO = read only.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The article you describe as "old" has #337 votes. There's a comment with code suggestions in Oct, 2016, which the author acknowledged.
Is it too much to ask that you review more than one article on CP (out of many) ? [^]. Or that you visit StackOverFlow, and sample possibly relevant sources.
"If not you, who ? If not now, when ?" (sometimes attributed to Hillel the Elder)
«While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it.» Claude Levi-Strauss (Tristes Tropiques, 1955)
|
|
|
|
|
BillWoodruff wrote: Is it too much to ask in this instance, probably.
|
|
|
|
|
I pointed out that it's old because AD has evolved over time. Some of the comments pointed out that there are newer ways of doing some of the things the article discussed.
BillWoodruff wrote: Is it too much to ask that you review more than one article on CP (out of many) ? [^]. Or that you visit StackOverFlow, and sample possibly relevant sources.
That's an assumption on your part that I haven't looked at other resources.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|