PlausiblyDamp
Administrators-
Posts
7016 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by PlausiblyDamp
-
Registry: Load, Save and Enumerate
PlausiblyDamp replied to moongodess's topic in Directory / File IO / Registry
Have a look at the Microsoft.Win32.Registry class and some of it's related ones - everything you need should be there. -
Is this a per user password or a system wide password or some combination? You might want to look at some of the classes under System.Security.Cryptography which deal with encryption.
-
ADO.NET sql server to access
PlausiblyDamp replied to anat2403's topic in Database / XML / Reporting
It really depends on how you are accessing the SQL server - if you are using stored procs (and you probably should) then depending on your version of access these may not be supported at all. Also the way OleDb and Sql handle parametrised queries (you should be using these as well) is different and will need to be changed. Without seeing any examples of your DB or .Net code though it is very difficult for anyone to offer any specific advice. -
If your string contains a CRLF then it isn't an empty string. If you want to display debug information then Debug.WriteLine(...) will do that for you. Also as a personal preference you might want to look at using some of the .Net equivalents to the legacy VB routines i.e. Dim pass As String = TextBox2.Text 'returndata is already a string If returndata.Trim() = String.Empty Then MessageBox.Show("Wrong ID") Else MessageBox.Show("Correct ID") End If
-
If you step through the code in a debugger or print the contents of returndata to the debug window what values does it contain? Does it every contain an empty string?
-
The problem lies with mis-configured mail servers, if a server is configured as an open relay then anyone can use it to send e-mail. This also means the source of the e-mail is difficult to trace. Such open relays are often used by spammers etc. as it obscures the true source of any e-mail you received. Banning by IP address of such badly configured servers is the only realistic way to handle them as SMTP allows anyone to fake a return e-mail.
-
Rather than the domain name you need to check iftheactual IP address of your mail server is listed.
-
Database Backup Routine - From VB2005 to C# 2005
PlausiblyDamp replied to jcrcarmo's topic in Directory / File IO / Registry
Ignore the code above, try the following - you just need to shove a using System.IO at the top of the source file. private void BackupToolStripMenuItem_Click(System.Object sender, System.EventArgs e) { string Time = DateTime.Now.ToString(" dddd dd-MM-yyyy à's' HH'h' mm'min' ss'seg'"); string FileName = "myDB " + Time + ".mdb"; string SavePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "myDBBackups"); if (!Directory.Exists(SavePath)) Directory.CreateDirectory(SavePath); File.Copy(Path.Combine(Application.StartupPath, "myDB.mdb"), Path.Combine(SavePath, FileName), true); MessageBox.Show("Backup performed succesfully. ", "Ready", MessageBoxButtons.OK, MessageBoxIcon.Information); } -
Not sure about the Express edition but VS 2005 allows you to define different configurations from the build menu - from there you can select the target architecture.
-
Also regarding comments, often a lot of simple comments could be removed just by using sensible variable, control and method names. Many times in the past I've encountered code along the lines of //Customer collection System.Collections.ArrayList cl = new ArrayList(); if a variable is going to hold a list of customers give it a name like, being radical here, CustomerList. This means the code is more readable rather than the comments being a required read, plus if you do modify the code you do not have to worry about the code / comments getting out of sync. Sensible comments like those suggested by Wile however are a must - explain the 'why we do this', 'what the expected parameters are' and 'desired results' so you can read over code and identify what a function is / does etc without having to read each line. Also it is very, very hard to produce good quality readable code while developing the code - refactoring as mentioned by marble_eater above is an essential skill; write code, check if it can be improved, tidied up or simplified and if it can do so before moving on. Using some form of additional tools like FxCop to check naming conventions etc will help. Unit tests with NUnit or similar mean you produce code that passes a set of tests and when you refactor you can guarentee that you haven't introduced bugs by re-running your tests. I can definately recommend This book as a good starter on using unit tests and getting into the refactoring habbit while coding.
-
Immediate Window "Unable to Evaluate the Expression"
PlausiblyDamp replied to rbulph's topic in General
? 7 + 3 worked just fine for me when I hit CTRL + BREAK... -
When the file is sent to your server it is just a stream of bytes without any meaning. The system doesn't care that it is a jpeg or not, a script or not - it will just pass a bunch of bytes. The only meaning impossed on the data is by what you choose to do with it - if you save it as a .jpeg then expect errors if you try to display it or read it into an image variable but that wouldn't be enough to cause the script to actually execute.
-
You need to grant the permissions to the SQL Server database either via Enterprise manager or through T-SQL. The two commands are GRANT and sp_grantlogin
-
Database Backup Routine - From VB2005 to C# 2005
PlausiblyDamp replied to jcrcarmo's topic in Directory / File IO / Registry
Probably the closest literal conversion is private void BackupToolStripMenuItem_Click(System.Object sender, System.EventArgs e) { string Time = DateTime.Now.ToString(" dddd dd-MM-yyyy à's' HH'h' mm'min' ss'seg'"); string FileName = "myDB " + Time + ".mdb"; string SavePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "myDBBackups"; if (!System.IO.Directory.Exists(SavePath)) { System.IO.Directory.CreateDirectory(SavePath); System.IO.File.Copy(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\myDB.mdb", SavePath + FileName, true); MessageBox.Show("Backup performed succesfully. ", "Ready", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { System.IO.File.Copy(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\myDB.mdb", SavePath + FileName, true); MessageBox.Show("Backup performed succesfully. ", "Ready", MessageBoxButtons.OK, MessageBoxIcon.Information); } } personally I would tend to avoid the VB specific functionality like MsgBox as it does make conversion / working with both languages easier. The following is the same but slightly tweaked to use more of the .Net functionality (mainly Path.Combine) to remove a chance of error when paths may or may not have leading / trailing slashes. EDIT: ignore the following code, fixed code is here private void BackupToolStripMenuItem_Click(System.Object sender, System.EventArgs e) { string Time = DateTime.Now.ToString(" dddd dd-MM-yyyy à's' HH'h' mm'min' ss'seg'"); string FileName = "myDB " + Time + ".mdb"; string SavePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "myDBBackups"); if (!System.IO.Directory.Exists(SavePath)) System.IO.Directory.CreateDirectory(SavePath); System.IO.File.Copy(System.IO.Path.GetDirectoryName( System.IO.Path.Combine(Application.ExecutablePath), "myDB.mdb"), SavePath + FileName, true); MessageBox.Show("Backup performed succesfully. ", "Ready", MessageBoxButtons.OK, MessageBoxIcon.Information); } -
You will need to grant the user account ANAT2005\ASPNET permission to access the SQL database.
-
Do it the other way round - design your context menu with the correct items and then on the menu strip go to it's DropDown property - then you can select your context menu and have it appear as part of the Main Menu.
-
Any chance you could give a bit more detail about how this works? How are you tracking orders and users? What kind of information are you storing? What code are you using to update / retrieve this information?
-
Have a look at the classes under System.Diagnostics - the Process class is probably the most useful in this case.
-
Also build with debugging information (even if doing a release build) as then you will get better stack trace information and that will help to locate the problem area.
-
Immediate Window "Unable to Evaluate the Expression"
PlausiblyDamp replied to rbulph's topic in General
Why don't you just put a break point on the line(s) you want to cause the app to break at? Doing a Break All will often result in the application being put into debug mode but outside of any actual runable .Net code - that is why you cannot evaluate any expressions etc. -
That is pretty much exactly what the thread pool is there for.
-
Find All Parent & Child Windows
PlausiblyDamp replied to Simcoder's topic in Interoperation / Office Integration
You would need to use the EnumWindows API to get all windows and the EnumChildWindows API for the children. http://www.pinvoke.net/search.aspx?search=enumwindows&namespace=[All] should be of some help. -
http://www.xtremedotnettalk.com/search.php?searchid=249250 - you should find enough information to get you started.
-
Also http://www.xmethods.net has a lot of free ones you can try, including a mixture of .net and non .net ones.