|
PIEBALDconsult wrote: SPACEs added to avoid smileys; remove them.
Whenever 4 or more spaces are present use t a b s
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:46 AM
|
|
|
|
|
I didn't want any SPACEs in the format at all.
|
|
|
|
|
The original code was mangled because of fixes required for smileys. Here is the correct code:
System.Console.WriteLine ( "{0 , 1 : + ; -}{0 , 7 : -O ; 0}" , 2009 ) ;
System.Console.WriteLine ( "{0 , 1 : + ; -}{0 , 7 : -O ; 0}" , -2009 ) ;
|
|
|
|
|
What I posted works fine for me (once the SPACEs are removed).
|
|
|
|
|
The best thing to do in this scenario is to create your own customer formatter and then pass it in as an argument.
String.Format(formatProvider, formatString, arguments). I have found this to be the only good way when dealing with phone numbers which may have bad data and I am sure it will provide you with that you need.
http://msdn.microsoft.com/en-us/library/system.iformatprovider.aspx[^]
|
|
|
|
|
It just might come to that. 
|
|
|
|
|
I have added padding support to my ApplyFormat method, so now 2009.ApplyFormat ( "' '+;-''6 : 0 ;0" ) will do that.
But now I want to cache the interpretation of the format specifier to streamline things a bit, so I'm not yet ready to update the article.
modified on Saturday, February 28, 2009 6:26 PM
|
|
|
|
|
Hi - can some one help me out here please - I'm new-ish to C#.
What are the performance implications of creating all my objects (forms, classes etc) inside one assembly versus splitting up the application over multiple assemblies?
I would prefer to keep every thing in one as I find it easier to work with and I won't get the cyclic error where by a form in one refers to a form in another which refers back to the original etc.
If I do put eveything in one assembly, will the application take longer to start up?
Will opening forms be quicker using the one as the app won't need to open more than one assembly to find the correct opened form etc?
Thanks
|
|
|
|
|
MarkB123 wrote: can some one help me out here please
Sure why not, click here[^]
I always enjoy helping the Google impaired.
|
|
|
|
|
I like. Less blatant than the original which practically required a tiny URL to slip past any but the blindest.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Fair enough - that did the job - I'll try not to be so lazy in future 
|
|
|
|
|
VS2005 C# This is my first C# project.
I have books, authors and a bkauthlink table linking the other two tables creating a many-to-many relationship. I get an error in Program.cs: one is a problem with the way I'm calling my main form; the other error may mean I have program.cs correct but there's a problem in my data class--specifically with the data relations involving a many-to-many relationship.
Program.cs class:
namespace BooksAuthors
{
static class Program
{
// The main entry point for the application.
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//error re single thread if use this
//"Starting a second message loop on a single thread is not a valid operation.
//Use Form.ShowDialog instead."
//Application.Run(new BooksAuthors.MainForm());
//error "Child list for field Authors cannot be created"
Application.Run(new MainForm()); }
}
}
Here's the class for the data:
namespace BooksAuthors
{
internal class ClassDataHandling
{
public void MainDataClass()
{
string connString = @"Server=RHOADESD;Integrated Security=True;" +
"Database=BOOKS";
SqlConnection conn = new SqlConnection(connString);
SqlDataAdapter booksAdapter = new SqlDataAdapter(
"Select * from books", conn);
SqlDataAdapter bkauthlinkAdapter = new SqlDataAdapter(
"Select * from bkauthlink", conn);
SqlDataAdapter authorAdapter = new SqlDataAdapter(
"Select * from authors", conn);
conn.Open();
DataSet BookAuthDataSet = new DataSet("BookAuthors");
booksAdapter.Fill(BookAuthDataSet, "books");
bkauthlinkAdapter.Fill(BookAuthDataSet, "bkauthlink");
authorAdapter.Fill(BookAuthDataSet, "authors");
conn.Close();
DataRelation book = BookAuthDataSet.Relations.Add(
"BookRel", BookAuthDataSet.Tables["books"].Columns["booksID"],
BookAuthDataSet.Tables["bkauthlink"].Columns["booksID"]);
DataRelation author = BookAuthDataSet.Relations.Add(
"AuthRel", BookAuthDataSet.Tables["authors"].Columns["authorsID"],
BookAuthDataSet.Tables["bkauthlink"].Columns["authorsID"]);
New to C#
modified on Friday, February 27, 2009 2:31 PM
|
|
|
|
|
Welcome to code project
It seems you have made some assumptions about how to use these forums. I suggest you take a look at the first message in this forum. Also click here[^] to read some forum guidelines.
Then keep in mind that you are asking people to help you for free. So take your time and attempt to provide complete concise information. For example your subject says "error message" but you did not seem to post the error message so no one here knows what it says. Secondly you posted code that is likely not relevant which means you did not take the time to formulate your post to optimize the time people will have to apply FOR FREE to help you.
|
|
|
|
|
I'm sorry. I have Googled for a couple days now and tried various things. This is my first C# project, I am teaching myself, and I have a many-to-many relationship between books and authors tables (linked by bkauthlink table) in SQL Server. No doubt it is not a good first project but it is what I have (a problem I need solved). There is not a great deal published on this scenario or I am googling the wrong terms. I have googled my error messages as well. And I did read how to post but have added to the subject and the body. I noted in the body of the code where the issues(s) happened but it seemed like a humongous subject line. I have one of two errors depending on how I call the form in my project. Any help would be greatly appreciated and if it were pleasant, all the more so. Thanks!
|
|
|
|
|
Diana Rhoades wrote: I am teaching myself
Diana Rhoades wrote: No doubt it is not a good first project but it is what I have
If you are teaching yourself then you should be able to pull the plug on a project that is not a good first project and start a new one.
Diana Rhoades wrote: There is not a great deal published on this scenario or I am googling the wrong terms.
There is a great deal published on all the topics involved in your scenario. However probably not one that matches exactly your combination of all the issues and technologies involved. This is why a developer needs to understand the basics of all the different technologies they need to use in a project, so that they are capable of integrating them all to accomplish the goals of the project.
Here is an excerpt from an Allen Holub article, where he discusses what things and why they are important for developers to know. (link to article)[^]
As far as I can tell, it’s because many so-called programmers just don’t know how to build a compiler. I really don’t have much patience for this sort of thing. To my mind, there is a minimum set of topics with which you have to be conversant to call yourself a professional programmer. If you don’t know these things, you’re a dilettante. This list includes a deep understanding of data structures and key algorithms, a little math (set theory, logic, a little statistics), mastery of analysis-and-design techniques, both process (e.g., RUP or XP) and structure (e.g., design patterns), and database structure and use (e.g., SQL). You also need to know how the hardware works.
You need this stuff even if you’re not actually using it in your work, because no matter what you’re doing, knowing this material will make your work better. How could you possibly decide which of Java’s Collection classes to use in a particular situation if you don’t know how those classes work under the covers, for example?
Knowing how to build a compiler is certainly one of the skills on this need-to-know list. Compilers are fundamental to what we do every day as a programmer. Knowing how the compiler works will let you make intelligent decisions about program structure, decisions that have real impact on the quality of our programs. More to the point, most programs have to parse input (either from a human being or from a machine) and make sense of it. To do that, you have to build a small compiler.
|
|
|
|
|
good day people
im searching through every directory in my computer with Directory.GetDirectories and Directory.GetFiles and when it gets to folders suchs as program files or documents and settings it gives me the "Access to path ... denied" exception, i have searched and found no answer yet, so is there really no way i can get around this exception? do i have to just skip these folders or can i do something to have access to them?
thanks a lot in advance
|
|
|
|
|
Hi,
yes, you might not have access to all existing folders (e.g. Vista prevents accessing the "System Volume Information" folder) so you need a try-catch inside the foreach that deals with accessing the individual folders. There are other things that might go wrong too, such as the local or networked drive disappearing, the folder disappearing, etc. so you need the try-catch anyway; without it the enumeration would suddenly come to a halt.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
well i guess i will just skip those damn folders
thanks a lot man
|
|
|
|
|
mirko86 wrote: i will just skip those damn folders
they exist, so they get reported by GetDirectories/GetFiles.
The method is not called GetAllFilesIWillBeAllowedAccessTo() you know.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:45 AM
|
|
|
|
|
Hello guys i would like to incorporate windows live maps with my application, the only problem is that my application is a windows application. Is it possabile to use windows live maps with a windows application? any ideas?
|
|
|
|
|
you can use a web browser control
|
|
|
|
|
ok thank you. Im gonna ask you another stupid question but worth a try.
For example I view some portion of the map and then the internet cuts, is it possabile to cache the view part of the map so that it can be viewable withour internet connection. Because in my project the application's scenario is based on a thrid world country.
|
|
|
|
|
Hello!
I have some code that add's users to my local administrator group.
But what i would like to accoplish is to add a user from an active directory to my localmachine admin group.
My code can add a local user to the local admin group.
I tried to alter the LDAP string for the ActiveDirectory connection but now it fails to add the domain user to the localmachine admin group.
The AD LDAP String: ldap://SERVERNAME01:389/CN=TESTUSER01,CN=Users,DC=DOMAIN01,DC=local
The Test String: WinNT://WORKGROUP/STEPHAN-F894E19/TestUser1
The Test String works the AD LDAP String doesn't work.
Can anyone help me with this?
Thanks!
the Code:
private void AddUserToGroup()
{
try
{
DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
DirectoryEntry grp;
grp = AD.Children.Find("Administrators", "group");
if (grp != null) { grp.Invoke("Add", new object[] { "WinNT://WORKGROUP/STEPHAN-F894E19/TestUser1" }); }
MessageBox.Show("Account Created Successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
|
|
|
|
|
i Found this code on CodeProject:
public void AddToGroup(string userDn, string groupDn)
{
try
{
DirectoryEntry dirEntry = new DirectoryEntry("LDAP://" + groupDn);
dirEntry.Properties["member"].Add(userDn);
dirEntry.CommitChanges();
dirEntry.Close();
}
catch (System.DirectoryServices.DirectoryServicesCOMException E)
{
}
}
But can anyone show me a sample LDAP String , UserDn String and a GroupDn String?
Thanks!
|
|
|
|
|
LDAP string - LDAP://CN=Administrator,CN=Users,DC=aDomain,DC=com
userDN - CN=aUser,CN=Users,DC=aDomain,DC=com
DN means distinguishedName
cool?
|
|
|
|