16,004,529 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 PeejayAdams (Top 62 by date)
PeejayAdams
4-Oct-19 9:24am
View
Yes the result would be the same in normal circumstances but what Richard is saying is that if you just append user text to the query string, your software is very easy to hijack.
What would happen if I enter the following in TxtSearch?
';DROP TABLE ReceiptVoucher
Always, always, always use Command.Parameters to pass an argument or you will be in a world of trouble!
Seriously, read some of the articles that Richard linked - SQL injection is one of the most common sources of security vulnerabilities in existence - this is such an important thing - understand it before you do anything else.
PeejayAdams
20-Sep-19 6:50am
View
Why not add a score property to your quiz object and increment it every time a correct answer is given? It sounds like the most basic bit of the task to me. Or is it that it's not actually your code?
PeejayAdams
5-Sep-19 7:03am
View
That looks very useful, thank you. I've been Googling for a more generic solution but it does appear to be something very odd in the EMGU set-up!
PeejayAdams
1-Jul-19 5:15am
View
Think about what 'd-m-Y' might be doing ...
PeejayAdams
21-Jun-19 9:56am
View
There's no inbuilt property of OpenFileDialog that will do that (though it would be rather useful!).
You could add code to the FileOK event to compare the path, otherwise you'll need to create your own version of the control.
PeejayAdams
17-Aug-18 6:48am
View
What kind of time variations are you getting? Is there any kind of pattern relating to which users are running the procedure?
PeejayAdams
13-Mar-18 12:30pm
View
Horses and water.
PeejayAdams
6-Mar-18 7:16am
View
Try looking at the SelectedValue property rather than SelectedItem. && is definitely the right operator.
PeejayAdams
2-Feb-18 9:47am
View
Would 52 be valid or would it need to be entered as 052? If both are valid, then you're simply looking at any number under 1000. If it has to be 052, then really you're looking for a string rather than an int, a regular expression ([0-9][0-9][0-9]) would be the way to go.
PeejayAdams
19-Dec-17 4:36am
View
Thanks, Richard. I certainly hadn't thought about STUFF. In this case, I still need to substring the description field down to the actual code but that certainly takes some of the complexity out of the equation. In the end, I used a CTE and applied a subsequent transfer on the final SELECT:
CASE
WHEN PATINDEX ('%J[A-Z][0-9]0%', [Phase Code]) > 0
THEN
REPLACE ([Phase Code], SUBSTRING ([Phase Code], PATINDEX('%[1-9]%', [Phase Code]), 1), '0')
ELSE
[Phase Code]
END
AS [Phase Code]
(creating a function wasn't an available option as it isn't our database) which certainly does the job but I can't help finding it a little untidy. Untidiness, I guess, is sometimes something we just have to live with in SQL - I'd sure hate to see an UNstructured Query Language!
PeejayAdams
12-Oct-17 11:25am
View
Hint: You've accidentally written most of the code required to return false in your "What I haven't been arsed to try" section - take three of the words, drop one of them, add a semi-colon and think about your life choices.
PeejayAdams
1-Jun-17 8:13am
View
It's very hard to say without seeing your definition for IDCursor and your declaration of @ID.
PeejayAdams
22-May-17 9:03am
View
Their documentation looks pretty good to me. They also have a forum which includes an FAQ section.
PeejayAdams
4-May-17 9:21am
View
Can you use something like: where !x.Contains("SearchPattern")?
PeejayAdams
27-Mar-17 6:51am
View
If you agree to paint my house, I'll agree to do your homework :) Seriously, you're not going to learn anything by copying my code or anyone else's (and it would pretty darned obvious to your tutor that you haven't written it yourself, anyway). Think about what you've been asked to do and have a go at doing it - that's what developers do for a living. If you get stuck on something specific, there are plenty of us here who are more than happy to help but at least TRY writing some code to get to that position.
PeejayAdams
27-Mar-17 6:32am
View
I don't think that your tutor wants you to write a program in multiple styles, he wants you to write some code that employs all of the basic OOP concepts.
PeejayAdams
6-Mar-17 5:56am
View
Yes, that looks fine to me, too. Make sure your <connectionstrings> segment is within the <configuration> tab and as F-ES suggests make sure you're dealing with the correct app.config file.
PeejayAdams
15-Feb-17 6:12am
View
I have both languages on my CV and I get about a 6:1 ratio of C#:VB.NET recruitment emails - obviously there's a regional element to that but it does seem broadly indicative. Whilst I take those "must-have IT skills" lists with a pinch of salt, it's notable that C# appears prominently on all of them whereas VB.NET rarely makes an appearance these days.
PeejayAdams
15-Feb-17 4:56am
View
The question asked which of the two languages is better to learn not where their commonality lies.
PeejayAdams
14-Feb-17 11:46am
View
That's an 8 year instant advantage for C#! Most languages hang around for a long, long time (I know a couple of people who still work with COBOL which is all the proof we could ever need) but I would imagine that there are far more green-field developments been undertaken in C# than there are in VB.
PeejayAdams
2-Feb-17 7:54am
View
WPF is awesome but it's quite a steep learning curve. Don't consider using WPF without the MVVM pattern, I've seen people try and it always ends in tears. If you're moving from VB to C# and trying to learn XAML, data bindings and MVVM at the same time, that year will fly by but you may not have too much to show at the end of it. If the app requirement doesn't dictate that you use WPF, I'd advise you to go with WinForms until you become more au fait with C#.
PeejayAdams
23-Jan-17 4:31am
View
That really is ridiculously slow, such things should be measured in milliseconds rather than minutes. Tempting as it might be to paper over the cracks, it really is unreasonable to expect the user to wait for that long - someone really needs to address the performance issue or you won't have 30,000 accounts for very long.
PeejayAdams
20-Jan-17 6:47am
View
I'd start by addressing the issue of why it's taking so long to perform the calculation.
PeejayAdams
17-Jan-17 9:51am
View
There are plenty of people here who are more than happy to help people out if they're stuck with something but not when they can't be bothered to even have a go themselves. Just getting someone to write your assignments for you isn't going to teach you a damned thing and it's unfair on your class mates who are doing it themselves rather than drafting in professional help. If you posted some code and said "this is what I've done but I'm struggling with aspect X", you'd get plenty of help on this site but as has been pointed out already, this is no different from me asking for someone to come and paint my house with no offer of payment (if anyone would like to do that, please give me a shout but I'm not holding my breath).
PeejayAdams
17-Jan-17 9:39am
View
Could we qualify that and maybe say "Yes, anyone could providing that they've done their homework?"
PeejayAdams
16-Jan-17 5:33am
View
It's an auto-generated partial class for your XAML and you can't stop it being generated. If you're having issues with one, do a clean and rebuild and it will get rebuilt. Why do you want to stop it being generated? If the problems appears to be coming from there it's most likely an issue in your code with missing/incorrect namespace references rather than with anything in the actual .g.cs file but you'd need to provide a few details as to what your actual issue is before anyone can help you with that.
PeejayAdams
3-Jan-17 10:28am
View
The camel/banana problem traditionally involves 3000 bananas - I'm almost certain that there's no solution if there are only 2000.
PeejayAdams
20-Dec-16 11:34am
View
Yes. Assignment goes to the left, so x = z would give x the value of z whereas z = x would give the value of x to z.
If we were assigning a value from a value rather than a variable we'd say, for example, "x = 2;" which effectively reads as "Let x have the value of 2." Similarly, when we say "x = z;" we are saying "Let x have the value currently assigned to z."
PeejayAdams
3-Nov-16 13:03pm
View
You need to loop through PostedFiles (plural) rather than looking at PostedFile (singular).
PeejayAdams
2-Nov-16 11:35am
View
Try this http://stackoverflow.com/questions/4019831/how-do-you-center-your-main-window-in-wpf
PeejayAdams
8-Sep-16 6:05am
View
It simply can't be done in a UDF. You could try using a CLR function.
PeejayAdams
6-Sep-16 5:02am
View
http://stackoverflow.com/questions/13948897/not-able-to-open-vb-project-getting-error-c-windows-system32-mscomctl-ocx-co
PeejayAdams
5-Sep-16 11:51am
View
Don't take my word for it because I don't know C++ but I'd try "if (f.compare("add") == 0)" in place of "if(f == "add")"
PeejayAdams
2-Sep-16 5:02am
View
Many thanks for that, PureNsanity. I've been somewhat sidetracked from the issue in question so haven't had a chance to readdress but I very much suspect that you've put me on the right track - will come back and accept as answer when I get the chance to go back and look at it but in the meantime, thanks again and +5!
PeejayAdams
26-Aug-16 9:02am
View
Deleted
You know the start point. You know the length of the string. You know the length of the date part. You already have all the information that you need.
PeejayAdams
25-Aug-16 7:47am
View
As pointed out in solution 2, you're replacing rather than concatenating. Your actual command text is "System.Data.SqlClient.SqlCommandwhere date_TripDate ='2016-08-24' and trip.int_
TripStatusID not in (0)" which is clearly not what you're after. If you really must do it this way, it should be cmd.CommandText += "something"; rather than cmd.CommandText += cmd + "something"; - cmd is a SqlCommand not the command text (also if doing a heap of string manipulation, do it in a StringBuilder would be a a better approach). As Solution 1 suggests - this really should be a stored procedure call, anyway.
PeejayAdams
1-Aug-16 10:52am
View
I would ask yourself the following questions:
1) Is Excel really the tool for the job? If yes, then you'll need to look into SSIS as a way to export from Excel to SQLServer. It won't be dynamic but you can automate the export of saved spreadsheets. It's not entirely clear what your requirement is but if you're trying to allow someone to maintain data, it's far, far better to do that via a form based app where you have control over validation etc.
2) Do you really want users to decide what fields get exported? (Hint: the answer you're looking for is a very firm "no!")
3) Do you need to update all 160 columns in a single procedure? I very much hope that your database doesn't have a 160+ column table. If it does, rewrite it/get it rewritten before you go any further.
PeejayAdams
28-Jul-16 11:50am
View
I can see plenty of problems there. Firstly, don't validate a number directly from a string - you check for "0" but "0.00" ".0" and many other things equate to zero. Your test for "0" is actually negated anyway as you effectively say "if (empty) ... if ([something we already know is true] or [it doesn't matter what goes here because we already have a true]) Your try ... catch block will only catch exceptions and you could be generating a fair few of those - how would you know where the exception came from? What about negative values?
In all honesty, I'm a bit confused by the whole thing and your question doesn't really give much clue as to what you're trying to achieve but if all you want to validate is that the product of the three is positive, you only need to test the product not look for individual zeroes.
PeejayAdams
26-Jul-16 4:23am
View
IIS User is a guest account so probably won't have sufficient permissions, try setting the application pool identity to a built-in account - LocalSystem should work.
PeejayAdams
25-Jul-16 11:34am
View
What account are you using on the application pool?
PeejayAdams
22-Jul-16 9:13am
View
You need to look at PIVOT (https://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx)
PeejayAdams
6-Jul-16 5:44am
View
Thanks, I did look at that route - and may have to go back there in some shape or form - it's not ideal because I simply can't predict all the places where the user might want to insert something. It's also problematic as it makes any global formatting changes somewhat difficult - this is a customer-facing document so needs to be WYSIWYG.
PeejayAdams
6-Jul-16 5:28am
View
The document in question is a summary of an estimate - it's potentially a very large document containing a combination of header details, text blocks, itemised activities with hours and prices and various comment fields. At present the summary goes out as it is generated from the data entered elsewhere in the application but we'd like people to be add to the generated parts of the document but not touch anything that relates to the stored data - e.g. we don't want people inadvertently adding a digit to a price.
PeejayAdams
3-Jun-16 5:24am
View
You need to do it anywhere after the for loop. Check that word is non-zero so that you don't get a result of 1 where you should be getting zero so if (word > 0) word += 1; would do the job.
PeejayAdams
3-Jun-16 5:17am
View
Hi shukla, by counting the spaces your always going to miss the last word so you'd need to increment your count by one for the final result.
PeejayAdams
3-Jun-16 5:05am
View
You're always checking the whole string to be a space (if (str = " ") rather than the specific character (something like if (Char.IsWhiteSpace(str[i]) ) - that's why your current code doesn't work. Split() would also do the job as Mehdi suggests but it wouldn't be suitable for large bodies of text as you'd be creating a huge number of objects.
PeejayAdams
16-May-16 11:03am
View
Have you tried ms-appx:///... (3 slashes rather than two)?
PeejayAdams
4-Mar-16 6:47am
View
There is something very wrong with your database design if you have a hundred columns in a table. If you don't address that first, anything you try to do in code is going to be a nightmare. Look at the basics of RDBMS and normalization before you go any further.
PeejayAdams
3-Mar-16 10:52am
View
Your code's kind of unreadable - proper casing and indentation would make a huge difference as would meaningful table aliases. Without any context or even an error message, it's somewhat hard to say what's causing the error.
PeejayAdams
22-Feb-16 9:32am
View
Thanks Nathan. It's certainly worth investigating, though I suspect it's going to turn out to be a very small needle in a very large haystack ...
PeejayAdams
22-Feb-16 9:15am
View
The VDI is running .NET 4.6 whereas my local is on 4.0 but that's never given rise to any issues in the past (both are running Windows 7 Pro). I'd expect .NET incompatibilities to give flat out errors rather than performance issues - though I could well be wrong on that.
PeejayAdams
11-Mar-15 7:55am
View
Thanks, CHill - sorry for the delayed reply - I'm suspecting that I'd used the non-SysWOW64 version of regsvr32 the first time round.
PeejayAdams
31-Dec-14 10:17am
View
Can you not just put it the Page_Load event handler?
PeejayAdams
31-Dec-14 9:24am
View
Does your FTP server support Unicode?
PeejayAdams
15-Dec-14 10:47am
View
That was the inspiration I needed, thank you!
I've changed my code to attach an XmlReader to the XmlWriter's FileStream and it does just what I want:
private static string GetRow<t>(object _data)
{
StringBuilder xml = new StringBuilder();
MemoryStream stream = new MemoryStream();
T data = (T)_data;
XmlSerializer serialiser = new XmlSerializer(typeof(T));
XmlWriter writer = XmlWriter.Create(stream);
serialiser.Serialize(writer, data, null);
writer.Close();
stream.Seek(0, SeekOrigin.Begin);
XmlReader xmlReader = XmlReader.Create(stream);
xmlReader.MoveToContent();
return xmlReader.ReadInnerXml();
}
PeejayAdams
5-Dec-14 7:19am
View
9839([0-9])\1{3}(?!\1)
would stop the next character being a repeat of the previous group by using a negative backreference but you'd need a separate check for the string being all numeric.
I suspect that someone out there will know how to combine both checks into a single regex.
PeejayAdams
2-Oct-14 11:57am
View
I don't know VB too well but shouldn't you be using a Byte array rather than a Byte for ProductPhoto?
PeejayAdams
9-Sep-14 10:34am
View
Thanks, Tadit. Your solution is certainly tidier than mine but the end result is exactly the same. I still get the updated panel appearing in the wrong place.
PeejayAdams
9-Sep-14 9:50am
View
Hi Tadit,
Yes it's happening in the AddParameterClick
protected void AddParameterClick(object sender, EventArgs e)
{
if (_parameters == null)
_parameters = new List<ProcedureParameter>();
foreach (RepeaterItem item in rptParameters.Items)
{
TextBox name = (TextBox)item.FindControl("tbParameterName");
TextBox value = (TextBox)item.FindControl("tbParameterValue");
_parameters.Add(new ProcedureParameter(name.Text, value.Text));
}
_parameters.Add(new ProcedureParameter());
rptParameters.DataSource = _parameters;
rptParameters.DataBind();
pnlSproc.Update();
}
PeejayAdams
26-Aug-14 8:28am
View
Reason for my vote of 2 \n Hi Mafaz, I certainly don't want to be too disparaging about anyone's first article but the points raised about terminology should be noted - the title is very misleading. As a historical aside, the ?: operator predates OO, it was part of the C language
PeejayAdams
21-Jul-14 5:34am
View
Thanks, Piebald but that runs into the same issue - I also get the same "invalid object" error if I run the commands via SMS. The problem really stems from going via a linked server. For my current purposes, I can work around it by making a direct connection to the server/database that contains the sproc in question and creating the temporary table there but that's a slightly untidy solution as I'll have to maintain multiple connection strings etc.
PeejayAdams
2-Jun-14 6:21am
View
Thanks tgrt - sorry for the delay in replying, I've been on holiday.
I've tried creating a stand-alone test form and everything works as expected as it does for you. So there's something in my app that's manipulating the IsDropDown property indirectly (maybe via the IsOpen property on the internal Popup) but I'm just not seeing it. I'll let you know when I find something.
Thanks again for having a look - it's much appreciated.
Show More