|
|
Initially, the success of running test was !true . After some work, it is !false .
|
|
|
|
|
|
|
The horror is allowing creation of a view with an order by in the first place.
Just say no.
|
|
|
|
|
My thoughts exactly.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Well, Order By is of some use, even in views.
But it should ALWAYS be paired with a TOP(X).
SELECT TOP 100 PERCENT *
FROM Somewhere
ORDER BY whatever
is a true, classic, horror.
|
|
|
|
|
Doing some maintenance on an application which I developed a few years ago, I found a small gem:
public string formatDateMySQL(DateTime date)
{
StringBuilder strTmp = new StringBuilder(date.Year.ToString());
strTmp.Append("-");
strTmp.Append(date.Month.ToString());
strTmp.Append("-");
strTmp.Append(date.Day.ToString());
return strTmp.ToString();
}
Yeah, formatting DateTime values works different everywhere, and that's a very "clever" way of coping with that...
License: You may use this code according to the CodeProject license.
|
|
|
|
|
Shirley AppendFormat is the way to go.
|
|
|
|
|
No, but ISO-8601 is IIRC.
|
|
|
|
|
Bernhard Hiller wrote: License: You may use this code according to the CodeProject license.
Don't you mean, "License: You must never use this code under penalty of tar-and-feathering"?
|
|
|
|
|
Just wait a little, and you'll see it becoming the solution for date/time formatting problems with MySQL server in Quick Answers...
|
|
|
|
|
Is this written in C#? I guess the more simpler way would be.
date.ToString("yyyy-MM-dd") out puts the date as 2012-04-18
or
date.ToString("yyyy-M-dd") out puts the date as 2012-4-18
If not C# Kudos to you
Sastry
|
|
|
|
|
ServiceCallInfo is actually a DataContract.
Yes... I have actually implemented a service that can call any other service it happens to find in it's configuration.
I'm sure none of this would be necessary in a dynamic language like Ruby, however what other framework/language provides such a comprehensive and flexible service framework like WCF?
I wasn't sure if this should go in "Clever Code" or "Hall of Shame" for it's meta-ness. I put it here, because I like to doubt myself
Right now it depends on all the service contracts being contained in one interface assembly though... I suppose I could also pass in the assembly name containing the contract and have it dynamically try to find or load the assembly too. Or would that be too far?
internal class ReflectedServiceChannelMethod
{
private static readonly Assembly InterfaceAssem = Assembly.GetAssembly(typeof(IGeneralLookupService));
private readonly Type _contractType;
private readonly Type _channelFactoryType;
private readonly object _channelFactory;
private readonly MethodInfo _createChannelMethod;
private readonly MethodInfo _callMethodInfo;
private readonly ParameterInfo[] _methodParams;
public ReflectedServiceChannelMethod(string interfaceName, string methodName)
{
_contractType = _interfaceAssem.GetType(interfaceName);
_channelFactoryType = typeof(EdsChannelFactory<>).MakeGenericType(_contractType);
_callMethodInfo = _contractType.GetMethod(methodName);
_methodParams = _callMethodInfo.GetParameters();
var channelFactoryConstructor = _channelFactoryType.GetConstructor(new Type[] {});
_channelFactory = channelFactoryConstructor.Invoke(new object[] {});
_createChannelMethod = _channelFactoryType.GetMethod("CreateDefaultChannel", new Type[]{});
}
public object CallService(ServiceCallInfo job)
{
object channel = null;
try
{
channel = _createChannelMethod.Invoke(_channelFactory, new object[] { });
var parameters = new List<object>();
foreach (var methodParam in _methodParams)
{
object value = null;
var paramType = methodParam.ParameterType.MakeByValType();
if (job.Parameters != null)
{
ParameterInfo param = methodParam;
var jobParam = job.Parameters.FirstOrDefault(p => p.Name == param.Name);
if (jobParam != null)
{
value = jobParam.Value;
}
if (paramType != typeof(string))
{
value = Convert.ChangeType(value, paramType);
}
}
parameters.Add(value);
}
return _callMethodInfo.Invoke(channel, parameters.ToArray());
}
catch (Exception ex)
{
ex.LogAsCritical();
return null;
}
finally
{
if (channel != null)
{
((IDisposable) channel).Dispose();
}
}
}
}
modified 29-Mar-12 14:07pm.
|
|
|
|
|
ObjectServiceFactoryServiceObjectAutomationLinkFactoryServiceFactoryObjectMetaObjectBuilderFactory .
Software Zen: delete this;
|
|
|
|
|
Gary R. Wheeler wrote: ObjectServiceFactoryServiceObjectAutomationLinkFactoryServiceFactoryObjectMetaObjectBuilderFactory .
You forgot "GoldProTeamEdition"...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
|
Let me be the first to congratulate you.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Just spent 1,5 hours on error which came out to be just a tupotypo. I had a simple WPF binding:
public static readonly DependencyProperty SopranTextProperty =
DependencyProperty.Register("SopranText", typeof(string), typeof(SeparateVoicesInputVM), new UIPropertyMetadata(""));
In a user-control. Tired of trying to get UserControl-HostWindow binding working (at least 4 hours), I have given up and broke design rules by pastying all the stuff to the MainWindow. Still, it didn't work. Time was passing while I was switching binding parameters with no effect. Finally, I decided to ask CP for this and, while writing a message, I have noticed one detail...
public static readonly DependencyProperty SopranTextProperty =
DependencyProperty.Register("SopranText", typeof(string), typeof(MainWindowVM), new UIPropertyMetadata(""));
Oh dear
Greetings - Jacek
|
|
|
|
|
|
The funny thing is that when get problems like this (not only typos), I too often find the problem when trying to explain it to someone else or while posting to a forum.
If only I would ask for help earlier, I wouldn't need it earlier too
"To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson
"Our heads are round so our thoughts can change direction." ― Francis Picabia
|
|
|
|
|
Let me second this observation. I have lost count of the number of times that I have found (mostly typo) bugs by trying to describe the problem to a coworker.
|
|
|
|
|
Back in school I once spent two days and several hours debugging a problem caused by an 'h' that was supposed to be a 'b', and vice versa.
Software Zen: delete this;
|
|
|
|
|
OK, Let me preface this by saying, I'm NOT a professional programmer. So I may be way off base and just lacking the knowledge as to why this may NOT be a piece of Shame. If there is a reason to do this, I'd love to know it..
Anyhow... Found this in some JavaScript in a vendor's product we pay plenty of money into monthly:
function ReturnFalse()
{
return false;
}
The only place I can find it used it in a couple statements like this:
if (button.onclick != ReturnFalse) {...
and
button.onclick = ReturnFalse;
Am I nuts or are they?
modified 13-Mar-12 14:25pm.
|
|
|
|
|
The shame is not what you think it is.
They are assigning a function to a click event. This function returns false. In JavaScript, this prevents the event from doing what it does by default. So, if you have:
<a href="#">Click Me</a>
And you assign the ReturnFalse function to it, clicking it will not append "#" to the URL. Without assigning that click handler, it would append that to the URL.
The shame is that they don't attach the event and that they compare the event to the function. They should avoid comparing completely, and they should use something like jQuery's $.bind function to add the function as a handler. Assigning a function to an event will replace all existing handlers, which should be avoided. However, if they wan't to remove all existing handlers, that may be the ideal approach.
|
|
|
|