|
Sorry, I think my comment was not clear. I was suggesting a reference to a variable that contains a specific value that the called method would recognise as a null value. However, the information we have been given seems somewhat less than complete - as is all too common.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
[Read this in conjunction with Davey's reply above]
I'm guessing here, but does GetMinMaxVals just return four doubles through the pointers you pass to it?
If so, then just call it with something like GetMinMaxVals(out double junk1, out double MaxX, out double junk2, out double junk3)
In other words, provide four places for it to put the results, and ignore the three you don't need.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Hi Peter, I am currently doing it the way you sagest, only problem is that it takes time to calculate each value and is making the UI a bit slugg like.
Thanks - John.
|
|
|
|
|
I am looking for either source code or a dll providing a multilingual keyboard for a windows forms C# touchscreen application. This could be either free for commercial use or paid for.
I have spotted the following WEB projects:
1./ A Multilingual Silverlight Virtual Keyboard
2./ JavaScript VirtualKeyboard
but need something non WEB based.
Any pointers would be greatly appreciated.
|
|
|
|
|
Hi,
I need my windows service to execute a routine depending on how old an entry in the Application event log is, i.e. if the last recorded event id (set by the routine) is older than 12 hours then run the routine again...
so, routine runs and writes...
if (!EventLog.SourceExists("mylog")) EventLog.CreateEventSource("mylog", "Application");
EventLog.WriteEntry("mylog", "routine run" , EventLogEntryType.Information,123456);
then, based on a timer...
DateTime lastexe;
EventLog eLog = new EventLog("Application");
foreach (EventLogEntry entry in eLog)
{
if (!entry.EventID == 123456)
{
List<datetime> lastrun = new List<datetime>();
lastrun.Add(entry.TimeWritten);
foreach(entry.TimeWritten in lastrun)
lastexe = lastrun.FindLast;
}
}
DateTime shouldrun;
DateTime rt = DateTime.Now;
if(rt > lastexe.AddHours(1))
{
}
As always, your help is appreciated.Thanks.
|
|
|
|
|
CCodeNewbie wrote:
Yup.
CCodeNewbie wrote: foreach(entry.TimeWritten in lastrun)
"entry.timeWritten" isn't a valid variable-name. This is the variable you can use in the loop. It also requires a type for that variable. Since your list is filled with DateTime objects, we can safely assume this type;
foreach(DateTime someDate in lastrun)
CCodeNewbie wrote: lastexe = lastrun.FindLast;
<a href="http://msdn.microsoft.com/en-us/library/5kthb929.aspx">FindLast</a>[<a href="http://msdn.microsoft.com/en-us/library/5kthb929.aspx" target="_blank" title="New Window">^</a>] returns the last item in the list that qualifies the conditions given.
Try something along these lines;
foreach(DateTime someDate in lastrun)
{
if (someDate > lastexe)
{
lastexe = someDate;
}
}
Using LINQ, that code would be effectively reduced to;
DateTime lastexe = lastrun.Max();
Bastard Programmer from Hell
|
|
|
|
|
I have a table which has columns like this
EmpID | Hours | Date
1 | 7.5 | 20110105
1 | 7.5 | 20110106
1 | 7.5 | 20110107
1 | 7.5 | 20110108
1 | 7.5 | 20110208
date means 2011-01-05
Now i want to get consolidated record of employees like this
EmpID | Hours | Date
1 | 30 | 01
1 | 7.5 | 02
for this i am using this in linq [of course some joins]
from lev in db.TimeTables
where lev.ActualDate.Contains(Year) &&
lev.PRJ_InternalID.Equals(36)
join
emp in db.Employees on lev.EMP_InternalID equals emp.InternalID
join
prj in db.Projects on lev.PRJ_InternalID equals prj.InternalID
select new LastYearVacationDetail
{
EmployeeID = lev.EMP_InternalID,
LeaveDays = lev.Hours,
Month = lev.ActualDate.Substring(5, 2)
}).ToList();
Now i am not getting Sum and not able to group.
Any help is appreciated
|
|
|
|
|
You could post this in the Linq forum[^]
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Hello,
I have an application that is composed of 2 forms. The first page launches the second page. On Page 2, I have a "Save As" button that launches a SaveFileDialog box, which works perfectly to save a file. However, whether I save or cancel, after it is done, the application closes Page 2 and restarts on Page 1. I want to application to simply return me to Page 2 where the Save As button is. I have tried several variations but have been unable to make it work that way. I am looking for a piece of code that will allow a new instruction when either Cancel or Save is selected from the SaveFileDialog box. I am including the save dialog code that I am using.
string savedFile = string.Empty;
SaveFileDialog saveFD = new SaveFileDialog();
saveFD.Filter = "Text Files|*.txt|All Files|*.*";
saveFD.Title = "Save a Text File";
if (saveFD.ShowDialog() != DialogResult.Cancel)
{
savedFile = saveFD.FileName;
richTextBoxSql.SaveFile(savedFile, RichTextBoxStreamType.PlainText);
}
else
{
}
Any suggestions are gratefully appreciated. Thank You..Pat
|
|
|
|
|
The code you have provided is fine and will not cause the form that calls this code to close. You must have this save as button set as the Accept or Cancel button for the form, or the button click handler contains the formname.close call.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Great Call Marcus....definitely a case of not being able to see the forest through the trees! I have this very poor habit of copying controls rather than making new one's, caused by my laziness when it comes to having to format. I may have done that with this button (or something else as foolish) and somehow managed to assign it the Cancel event. I gratefully gave you a fast five for this one. Best to all that replied. I truly do appreciate it. Luc...thank you for your input. Nice to see you replying to me again...Pat
|
|
|
|
|
I tried pasting your code into a form, and displaying the form via both Show and ShowDialog. Even with an AcceptButton and a CancelButton defined, I could not make it close the form by closing the SaveFileDialog with the mouse on either button, or with the ENTER or ESC keys.
In short - I cannot duplicate your problem from the information you have given. What are you doing that I am not? Have you tried removing code until it does work, then putting it back until it stops again?
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
OriginalGriff wrote: Have you tried ... putting it back until it stops again?
Now why would he want to do that?
Seriously, removing code to deal with a bug is fine, most bugs are in code you don't really need anyway; putting the bugs back in is a bit weird though.
|
|
|
|
|
Take away in huge chunks: problem goes away. Put back smaller chunks: problem comes back. Your bug is now in a smaller bit of code, so repeat the process until you have a manageable code size that demonstrates the problem.
I do like to be able to replicate bugs before I try to fix them...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Got my five on this one, which I think deserves posterity via some "idiom."
My suggestion: "kill code until live: resurrect code until death."
Actually it's a technique I use quite often to isolate bugs, along with trying to reproduce the bug "outside" the original context by creating a special test-case mini-app, or replacement class, or whatever.
best, Bill
"Anyone who shows me my 'blind spots' gives me the gift of sight." ... a thought from the shallows of the deeply shallow mind of ... Bill
|
|
|
|
|
How are you implementing your pages? are you using a tab control? On which pade is the rich text box?
|
|
|
|
|
Hello everybody, and sorry for my bad English, I'm trying to draw Wave forms from a wave file.
I know that in .Wav files data are codified by the PCM technique, and that i have 16 it for each amplitude coded.
So I came up with this code:
private void Plot()
{
int Num = 0;
WaveChart.Series.FindByName("WaveSerie").Points.Clear();
Double Dx = 1 / Ws.CurrentHeader.SampleRate;
for (int i = 0; i < Ws.CurrentBuffer.Length; i += 2)
{
Num = ((Ws.CurrentBuffer[i + 1] * 256) + Ws.CurrentBuffer[i]);
WaveChart.Series.FindByName("WaveSerie").Points.AddXY(Dx * i, Num);
}
}
It just take the 2 bytes read form the .Wav file, and merge them in order to make a 16 bit number, then It tries to draw the point obtained.
But it don't work, because I get an incorent drawing:
http://postimage.org/image/q647gboon/[^]
The correct Wave form is this [From Audacity]:
http://postimage.org/image/9bbrgrwcb/[^]
Ws is just a Class which read a .Wav file and puts in CurrentHeader the file header and in CurrentBuffer the Wave data.
Num is the number obtained by merging the 2 bytes from current buffer, it is the wave amplitude.
Where is the mistake ? Thank you, and sorry again for my English.
|
|
|
|
|
Hi,
in C# int and short are signed, however byte is unsigned by default.
I bet you're using an unsigned byte array, in which case your two-byte to integer conversion is wrong.
A simple if(x>=0x8000) x-=0x10000; could fix it.
|
|
|
|
|
Oh, such a stupid error ! It works ! Thank you very much !
|
|
|
|
|
You're welcome.
|
|
|
|
|
I want to import data from excel to sql server 2005. I am using C# for this purpose. I successfully exported the data of general format
to varchar. But, the problem arises while exporting the data of date type.
I have used date format in excel and want to export it in sql server 2005's datetime field.
The code that I have used is:-
SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection);
sqlBulk.DestinationTableName = "Data_Master_Inventory";
sqlBulk.ColumnMappings.Add("VendorRegistrationNo", "VendorRegistrationNo");
sqlBulk.ColumnMappings.Add("ProductCode", "ProductCode");
sqlBulk.ColumnMappings.Add("SerialNo", "SerialNo");
sqlBulk.ColumnMappings.Add("VendorProvidedSerialNo", "VendorProvidedSerialNo");
sqlBulk.ColumnMappings.Add("ModelName", "ModelName");
sqlBulk.ColumnMappings.Add("ProductCategoryCode", "ProductCategoryCode");
sqlBulk.ColumnMappings.Add("InventoryDate", "InventoryDate");
sqlBulk.WriteToServer(dReader);
Please provide me necessary solution.
|
|
|
|
|
Hi Rahul
U can refer these links
http://www.sqlteam.com/article/use-sqlbulkcopy-to-quickly-load-data-from-your-client-to-sql-server
http://www.codeproject.com/KB/database/SqlBulkCopy.aspx
http://www.codeproject.com/KB/database/TransferUsingSQLBulkCopy.aspx
http://stackoverflow.com/questions/2238328/sqlbulkcopy-writetoserver-example-what-am-i-doing-wrong
Thanks
Ravindra
|
|
|
|
|
Please use the appropriate editor buttons to make your links clickable.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
It's gonna be one of those kinds of days...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
No change there then.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|