|
Luc Pattyn wrote: As it smells like a MIDI app
Good guess. I had to suspend work on what I was doing a few months ago due to other pressures. I've recently picked it up again and trying to clean up some of the parts I wasn't totally happy with before. The wrapper is pretty much complete and tested - next step will be to write a few simple demos to show it off. Article pending ... I'll include a few samples of my musical work in there too
Dave
"My code works, but I don't understand why!" - DaveyM69 (Me) BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
DaveyM69 wrote: Article pending ...
will "My code works, but I don't understand why!" apply?
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
I don't know if you caught that thread or not - it's here[^] if not.
It is part of this same project. It was actually a bit of a repost with a solution I discovered accidentally to a problem that I never fully resolved before. If you can shed any light on this and/or would like to see the real code let me know. I'm still not 100% sure why it works amd I may be relying on undocumented behaviour by the GC which worries me as it may change and break this safety net. On the other hand, if it works that way by design then cool
Dave
"My code works, but I don't understand why!" - DaveyM69 (Me) BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi Dave,
yes I had seen part of that thread at that time. I'll reply to it now.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Hey there,
I have a c# project and I'm working in VS 2005 and .NET V2 SP2. I also have a web service built in Java that runs on jBoss 4.2.3. In this web service is a method that originally took a number of parameters that kept growing in size over time. Some of these parameters were of type long[].
The web service method was recently changed so that instead of having several parameters it had a single parameter which was an object that contains all parameters. This made it so that whenever we added new functionality to the method it's stub would not change.
Now when I update my reference in the c# project I see the single object but contained within that the long[] parameters are now long?[], which are nullable of course. I don't want this as it could break the existing code if a comsuming app were to pass in an array with null elements.
Can anyone please explain why it is doing this and if there is way of preventing this?
Thanks!
Brian
|
|
|
|
|
I'm working on a solution that pulls in components from different projects. I have my Data Access class, some custom controls I wrote, my App Security class, and the WinForm components. All of these access data, and so far, all of them use their own connections.
I was thinking about creating a ref to my data access class in each project that needs data. I would also include a Connection property that, if populated with an open connection, would be used so that in most cases, I'd only ever have one connection to the data source. If the connection property has not been populated, then the class would establish it's own connection using the data access class.
Any thoughts on this?
Everything makes sense in someone's mind
|
|
|
|
|
The connections should only be created in the data access object(s). There shouldn't be any reason for the other components to create a connection and pass it to the data access class. Doing so runs the risk having the connection opened far longer than necessary, or having it closed by the time the data access needs it, plus other design and maintenance concerns.
only two letters away from being an asset
|
|
|
|
|
Yes, but wouldn't that result in multiple connections open? I'v always heard that an app should only have one, maybe two, open connections.
Everything makes sense in someone's mind
|
|
|
|
|
Kevin Marois wrote: but wouldn't that result in multiple connections open?
Only if you allow it to. You could make the data access component a singleton. However, the chance of having multiple connections open is minimal if you fallow the rule that the connection should be opened as late as possible and closed as soon as possible.
only two letters away from being an asset
|
|
|
|
|
Hi,
I want to use a DetailsView to insert a record into an empty list.
I have a DetailsView in my page source (DefaultMode set to insert), and the datasource in set in the codebehind.
myObject = new CustomObject();
if (!IsPostBack)
{
myDetailsView.DataSource = new List<customobject>() {myObject};
myDetailsView.DataBind();
}
...Then I run the website and type some text into one of the bound fields,
then click a button on the form...
protected void Button_Click(object sender, EventArgs e)
{
string s = myObject.myProperty;
}
But the value of the object is NULL.
Even myDetailsView.DataSource returns an empty list
what am I doing wrong??? I just want to retrieve the values types into the DetailsView
Thanks
James
|
|
|
|
|
jehazlam wrote: what am I doing wrong???
The first thing is not asking this in the ASP.NET forum.
jehazlam wrote: But the value of the object is NULL.
Your object is null because you have not persisted it in any way.
jehazlam wrote:
Even myDetailsView.DataSource returns an empty list
if (!IsPostBack)
{
myDetailsView.DataSource = new List() {myObject};
myDetailsView.DataBind();
}
Of course its empty, your're not re-binding it during your postback
Mastering ASP.NET DataBinding[^]
only two letters away from being an asset
|
|
|
|
|
I am running a SQL statement in C#, where I am using the WHERE clause to limit a query to a date.
Here's the SQL:
DbCommand.CommandText = "SELECT SUM-DATE, SUM-STORE, SUM(SUM-RETURNS) FROM SUMMARY WHERE SUM-DATE = '" + dtProcDate + "' GROUP BY SUM-STORE";
The dtProcDate is assigned here:
if (DateTime.Now.DayOfWeek == DayOfWeek.Monday)
{
dtProcDate = DateTime.Now.AddDays(-2);
}
else
{
dtProcDate = DateTime.Now.AddDays(-1);
}
When I query just the date, I get the date in the MM/DD/YYYY HH:MM:SS AM/PM format, which is what dtProcDate shows as it's format also.
Here is the Error:
ERROR [HY000] Data Type Mismatch in WHERE clause, Value '10/24/2009 2:22:39 PM'.
What am I missing here?
Jude
|
|
|
|
|
Let me know what database you are using??
check this :
here[^]
|
|
|
|
|
Thanx for the link.
The database is System Z.
I am no longer getting a type mismatch. I changed dtProcDate to dtProcDate.ToShortDateString(), but I am not getting the result I want.
Jude
|
|
|
|
|
Depends. The most likely pair are:
1) SUM-DATE is not a DateTime.
2) Your datetime format is not what the database is expecting. Remember that
string + DateTime + string is an implicit
string + DateTime.ToString() + string which means it is formated to your current default environment - in this case "dd/mm/yyyy". Try changing to
dtProcDate.ToString("yyyy-MM-dd HH:mm:ss"); and you should be fine.
See here for DateTime.ToString formats[^]
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Thanx, but that gives me a syntax error.
When I do dtProcDate.ToShortDateString(), I do not receive an error, but I do not get the results that I need.
This SQL statement worked in Access....
Jude
|
|
|
|
|
SQL statements based on ToShortDateString() make absolutely no sense to me, as that method relies on the Regional Settings whereas a database should not be localized. You really should use an explicit format specification as in ToString("yyyy-MM-dd")
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
True. I was trying it for troubleshooting.
When I query just the date I get a MM/DD/YYYY HH:MM:SS AM/PM in return.
When I use just the dtProcDate in a compare, I receive an error of Syntax Error: Unprocessed input. Net token '6' (which is the hour of the time).
When I try to use either # or quotes around the date I receive Syntax Error: Required text missing. Next token '#'.
When I try a dtProcDate.ToString("MM:dd:yyyy hh:mm tt") I receive a Syntax Error: Unprocessed input Next Token: '06' (which is the hour of the time here).
I am at a loss. I have never had this much trouble comparing dates!
Jude
|
|
|
|
|
TheJudeDude wrote: I was trying it for troubleshooting
troubleshooting code better be correct too.
TheJudeDude wrote: When I query just the date I get a MM/DD/YYYY HH:MM:SS AM/PM in return
No. the database returns a date, which is a struct containing some numbers. And for human consumption your PC converts that into a string, according to some rules, by default influenced by the Regional Settings. That Control Panel is exactly how the human user tells the system what he likes to use as date and time formats. An explicit formatting string allows you to specify a different format, independent of Regional Settings.
SQL wants date/datetime according to ISO 8601, which means dashes in the date, colons in the time, year-month-day order, a 'T' in between, etc etc. The delimiter (quote, hash, whatever) may depend on the exact database.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Thanx for the input. Are you familiar with System Z?
Jude
|
|
|
|
|
TheJudeDude wrote: Are you familiar with System Z?
No I'm not. Google knows about it. Seems to be an IBM thing. If this isn't all happening on a Windows PC, how does it fit the C# forum at all?
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Yes google knows about it, just thought I may ask you. All I am looking for is to make a date comparison work. The database is on a Red Hat server. I need to make reports from the data through an ODBC connection from a Windows platform.
There is very little documentation from the provider and the support is spotty. The company I work for just changed our POS software and I am trying to put out the same reports that management are used to having.
Well, thanks for your input so far.
Jude
|
|
|
|
|
if all documentation were missing, I would try a few experiments on a DATE field:
SELECT * FROM tablename WHERE dateFieldName='2009-10-27'
SELECT * FROM tablename WHERE dateFieldName=#2009-10-27#
SELECT * FROM tablename WHERE dateFieldName=`2009-10-27`
or on a DATETIME field, same tests however replace = by >=
all this assumes a new record got added with dateFieldName set to NOW() or CURDATE() or whatever yields the current date or datetime.
And of course my entire test would sit in a try-catch with the catch displaying exception.ToString()
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Thank you so much for your help!
But...here is the report:
Single quotes, '10/25/2009' returns an error of Type Mismatch in WHERE clause, value '10/25/2009'
A pound around the date returns an error of Syntax Error: Required text missing. Next token '#'
The ` character around the date returns the same as the previous. (thought this was the one that would work due to using ` in bash scripting and this being a *nix server)
Using the DateTime field dtProcDate by itself returns an error of Unprocessed input. Next token '8' (which is the hour of the day)
Doing the same on >= would yield the same result.
The data is updated daily at midnight local time, so the data is static for the date used.
And all is set in a try/catch.
These pretzels are making me thirsty!
Jude
|
|
|
|
|
For the last time, it is bound to be #year-month-day# where # is some special character
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|