Below pasted is the piece of code where I want to display records based on the date range.
Let's say I have a startDate(01/15/2007) and an endDate(01/15/2008):
Can anyone give me some inputs as how to handle date validation in this code. I mean the place where I'm concatenating those 4 columns and getting a single date column row by row, I want to have this date validation. If it falls within this range, it shud add to the DataSet as a new row or else no.
DataSet newPDS = new DataSet();
DataRow row = new DataRow();
<code>//ADM_DATE is DateTime field in DataSet</code>
<code>//Checking whether column is already created or not</code>
if (newPDS.Tables.Columns["ADM_DATE"]== null)
DataColumn dCol = new DataColumn(newPDS.Tables.Columns.Add("ADM_DATE", typeof(DateTime), "").ToString());
for(Int32 i = 0; i < newPDS.Tables.Rows.Count; i++)
row = newPDS.Tables.Rows[i];
<code>//Concatenating 4 columns and filling up a date column (ADM_DATE) row by row</code>
row["ADM_DATE"] = row["CADMMM"] + "/" + row["CADMDD"] + "/" + row["CADMHH"] + row["CADMYY"];
Any help would be appreciated. Thanking you in anticipation.
Why do you have the date stored in four columns in the first place? That makes it mostly useless...
that's infact a million $$$ question...........the dates stored in AS400 (mainframes) systems are in this format only...........and moreover, they dont have a date field as such.......... (i said wtf???? wen i first saw this format, thn i learned its Mainframes)..........
anyway, with couple of changes in the code i've done the date validation.........but its showing all records in the report............i don't want it that way............date validation is working fine, but its working only on the "ADM_DATE" column.........
hold on, i'll explain.........suppose a row of record falls within the given date range, then in the report as expected its displaying the entire row............but when its not falling within the date range, still its displaying the row of record, but keeping the date field as empty............
did i explained the situation clearly..........pls see the code below:
Hello, I'm receiving the following error message. I know I'm missing something simple, but I can't figure out what it is.
Possibly a local DLL security issue? I have been able to reference winmm.dll 's other methods without a problem though.
The only thing I can think of is I'm sending invalid Types.
Tested in VS 2005 (.NET 2.0), and C# Express 2008 (.NET 3.5)
I'm not an expert at making native calls but there are a few things that don't look right to me.
1) C# long is not necessarily the same as C/C++ long.
2) In mciGetErrorString param #3 represents the length of the buffer that param #2 points to, but you're passing in an empty string which is length zero and telling mciGetErrorString that it's 128 chars long. I think to return a string from native code to managed code you need to create a StringBuilder of the appropriate length and use that. In the article you linked to see how he used a StringBuilder for the variable strReturn in the declaration of mciSendString even though when he calls that function he passes null for the string pointer and zero for the length.
Yep, you guys were right on. The C++ to C# conventions types threw me a bit off. TY TY.
Now... You wouldn't have any idea why I can make winmm.dll MCI device calls from a windows forms app but not a console app? I believe a windows forms app uses the default sound device, but the console app attempts to use it (the default one windows is probably holding onto) and windows tells it...
"Unknown problem while loading the specified device driver."
This error shows up regardless if the audio file path is valid or not.
I would think the windows console process would have access to the windows audio devices.
I used the final code below to generate the error. Works in a form app, not in a console app.
VS 2005, and C# 2008.
Code is as follows...
[System.Runtime.InteropServices.DllImport("winmm.dll", EntryPoint = "mciGetErrorString")]
public static extern bool mciGetErrorString(int dwError, StringBuilder lpstrBuffer, int uLength);
private static extern int mciSendString(string strCommand, string strReturn, int iReturnLength, IntPtr hwndCallback);
static void Main(string args)
string Pcommand = "open \"" + "C:\\SomeNonExistantFile.mp3" + "\" type mpegvideo alias MediaFile";
int err = mciSendString(Pcommand, null, 0, IntPtr.Zero);
StringBuilder text = new StringBuilder(128, 128);
mciGetErrorString(err, text, int.MaxValue);
Console.WriteLine("Press Any Key");
audio yes, but video no. the type in your Pcommand is mpegvideo, but should a console app be able to play movies? the command succeeded when i tried it with a type waveaudio..
Also, if you pass a value into mciGetErrorString that is larger than the space that you have allocated for the buffer, then it will be able to write to invalid memory. Since the SB has a capacity of 128 it makes sense to pass in 128 instead of int.MaxValue
Yeah, good call on the SB, I just ran into the overflow problem. I made that change. Thanks!
Your right concerning the type also.
The reason I was using the mpegvideo instead of waveaudio was the decoder/codec functions of the mpegvideo option (specifically MP3's) eg. console mp3 player. From what I can tell, I have been unsuccessful in getting waveaudio to use MP3's. I believe it was designed for raw WAV's only.
I was hoping to stick with winmm.dll for the consistency. Any suggested workarounds? Time for a new lib?
DWORDs will never be a C# long - they are always unsigned 32-bit ints.
A BOOL is an int, which is a 32-bit signed int.
As Jimmanuel mentioned, you also can't use a string as an out parameter like that.
Put that all together and something like this should work: