|
We can't give you any specifics, because you don't give us any specifics.
But basically, you want to run a query on the database which is along the lines of:
SELECT COUNT(userName) FROM myTable WHERE userName='DoesThisExist' If it returns a non-zero value, then the username exists.
(By preference, make this a parametrized query, or you leave your database open to SQL Injection attack which can damage or destroy it)
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
The number of tiers doesn't matter.
|
|
|
|
|
Don't get so hung up on "3 tier" and stuff like that.
You have a very specific problem you are trying to solve so just focus on that alone.
What you need to do is run a query against your database to check if a value exists. That's it.
public bool UserNameExists( string username )
{
}
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Hi,
I had been working on C, C++, VC++ technologies for many years. I want to start learning C# .Net. I have little knowledge about C#.Net. I want to know from where to start.
And also what is the difference between C#, .Net, ASP.Net, ADO.Net etc etc ..
Any good books OR Tutorials to start from.
Any suggestion is welcomed.
Regards,
Mbatra
|
|
|
|
|
The important thing is to find a book or course in your native language - this makes life a lot easier for you because you aren't also trying to translate English while you learn.
After that, the Addison Wesley, Wrox, and Apress books are generally pretty good - just read it from start to finish and do all the exercises to make sure you don't miss anything too fundamental. Just avoid any books with "in XXX days", "For Dummies" or multiple exclamation marks in teh title!
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
|
CLR via C# is my personal recommendation to learn indepth about the framework.
If you just want to start learning programming, any good book will help you.
|
|
|
|
|
How advisable to use Socket.Select() with infinite wait option?
Socket.Select(IListClientRead, null, null, -2);
I am using thread for Receiving Data using select method. On first connect it works fine, but when I reconnect, the Socket.Select statements blocks forever.
Suggest a good link as a programming reference for
C#, sockets, multithreading
|
|
|
|
|
Lots of suggestions here[^].
|
|
|
|
|
Or better yet, ditch your C# sockets and go here[^]
|
|
|
|
|
Suppose I have an array of n elements ( for example double or string) I want to display them in the console in 2 columns, having the same number of elements and keeping the order.
if my
string[] my = new string[]{"a","b","c","d","e"} I need to display
a d
b e
c
So first column a b c
second column d e
First and second column should be spaced
It is like a menu
Any smart idea?
|
|
|
|
|
Something like this:
string[] my = new string[]{ "a", "b", "c", "d", "e" };
int midPoint = (my.Length / 2) + (my.Length & 1);
for (int i = 0, j = midPoint; i < midPoint; i++, j++)
{
Console.WriteLine("{0}\t{1}", my[i], (j >= my.Length ? null : my[j]));
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
I am testing code that uses backgroundWorker. A similar application run on a different computer runs code that is practically the same, and is faster, but doesn't use backgroundWorker. Could the backgroundWorker be taking longer than code that doesn't use the backgroundWorker? Other differences are 32 bit vs 64 bit(mine)computer. My code also uses more dll's, but using a profiler with my code, the part that was taking long was a repeated call to an external dll, which the other code also does.
|
|
|
|
|
If it's done wrong, sure. Plus multi-threading adds more complexity which can mean things like checking a semaphore and locking. This could lead to lessened performance, but that could just mean that the problem isn't suited to multi-threading.
We'd need to see the code to be sure.
|
|
|
|
|
Maybe the problem is with how I create the backgroundWorker. From my form class, I am doing the following (I create two of these..one for each form tab):
if (!backgroundWorker1.IsBusy)
{
try
{
backgroundWorker1.RunWorkerAsync();
}
}
Is there a way I can still have the user able to hit a button on the form, yet have the backgroundWorkers hog more of the processor so they can have priority over the form and other things on the computer?
|
|
|
|
|
I just use Threads, not BackgroundWorkers, and I always set them for lower Priority.
|
|
|
|
|
I am testing code that uses backgroundWorker. A similar application run on a different computer runs code that is practically the same, and is faster, but doesn't use backgroundWorker. Could the backgroundWorker be taking longer than code that doesn't use the backgroundWorker? Other differences are 32 bit vs 64 bit(mine)computer. My code also uses more dll's, but using a profiler with my code, the part that was taking long was a repeated call to an external dll, which the other code also does.
|
|
|
|
|
The answer is that you aren't comparing the same thing here. What BackgroundWorker does is allow your code to run asynchronously, which simplistically means that the computer will allocate time to run the code on a different thread. This means that there is no guarantee when the code in the async side runs - or completes.
When you run the code on the primary thread, then all the time that your program is running this section of code is allocated to it (assuming you haven't created any other threads), but you will block the primary thread here. I would suggest that you have a read about threading, and investigate the Task classes that make asynchronous code a lot easier.
|
|
|
|
|
It looks like I had this question post twice. I put a response on the other one. That would be great if we could switch the primary discussion to the other posting. Thanks!
|
|
|
|
|
Maybe the problem is with how I create the backgroundWorker. From my form class, I am doing the following (I create two of these..one for each form tab):
if (!backgroundWorker1.IsBusy)
{
try
{
backgroundWorker1.RunWorkerAsync();
}
}
Is there a way I can still have the user able to hit a button on the form, yet have the backgroundWorkers hog more of the processor so they can have priority over the form and other things on the computer?
|
|
|
|
|
Not with a background worker - the whole point is that it's meant to work in the background. If it has a higher priority, then this would slow down your application and will lead to a poor user experience.
|
|
|
|
|
I created a class so I can add extensions to the GroupPrincipal object but I am getting this error:
System.InvalidOperationException: Principal objects of type CloudPanel.AD.Custom.GroupPrincipalExt can not be used in a query against this store. at System.DirectoryServices.AccountManagement.ADStoreCtx.GetObjectClassPortion(Type principalType) at System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRefHelper(Type principalType, String urnScheme, String urnValue, DateTime referenceDate, Boolean useSidHistory) at System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRef(Type principalType, String urnScheme, String urnValue, DateTime referenceDate) at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable`1 identityType, String identityValue, DateTime refDate) at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(PrincipalContext context, Type principalType, IdentityType identityType, String identityValue) at CloudPanel.AD.Custom.GroupPrincipalExt.FindByIdentity(PrincipalContext context, IdentityType identityType, String identityValue) at CloudPanel.Exchange.ExchPs.Get_DistributionGroup(String distinguishedname)
I don't really know why this isn't working since I have used this class before.
Here is a piece of the class I created (I didn't include all the DirectoryProperties since there are a bunch that I've added):
public class GroupPrincipalExt : GroupPrincipal
{
public GroupPrincipalExt(PrincipalContext context) : base(context) { }
public GroupPrincipalExt(PrincipalContext context, string groupName) : base(context, groupName) { }
public static new GroupPrincipalExt FindByIdentity(PrincipalContext context, string identityValue)
{
return (GroupPrincipalExt)FindByIdentityWithType(context, typeof(GroupPrincipalExt), identityValue);
}
public static new GroupPrincipalExt FindByIdentity(PrincipalContext context, IdentityType identityType, string identityValue)
{
return (GroupPrincipalExt)FindByIdentityWithType(context, typeof(GroupPrincipalExt), identityType, identityValue);
}
[DirectoryProperty("wWWHomePage")]
public string WWWHomePage
{
get
{
if (ExtensionGet("wWWHomePage").Length != 1)
return null;
return (string)ExtensionGet("wWWHomePage")[0];
}
set
{
this.ExtensionSet("wWWHomePage", value);
}
}
}
Here is how I am calling it:
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "dc.******.local", "DC=*****,DC=local", ContextOptions.SimpleBind, "******\\Administrator", "*********"))
{
GroupPrincipalExt group = GroupPrincipalExt.FindByIdentity(pc, IdentityType.DistinguishedName, distinguishedname);
if (group != null)
{
}
}
Any idea why this would be happening?
|
|
|
|
|
Have you tried adding the DirectoryObjectClassAttribute[^] to your GroupPrincipalExt class?
[DirectoryObjectClass("group")]
public class GroupPrincipalExt : GroupPrincipal
{
...
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Ahhh!! You are awesome. I copied and pasted the class and didn't copy it!
That fixed it. Thank you so much
|
|
|
|
|