|
I don't quite know what you are trying to do but one thing that stands out is you are checking to see if the array length is big enough after you access the data. If you want to check if it is available to access then do it before the switch.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Ah im just using it to check that i have recieved the correct number of bytes.
If there are more than three bytes in the recieved array then something is wrong throwing an exception.
In other words checking nothing follows the Version number request
|
|
|
|
|
switch (rxMessage[2]) <- change to rxMessage[1] since arrays starts at 0.
rgds Tomas
If it' stuck, DO NOT pull harder!
|
|
|
|
|
byte 0 and one are filled i didnt add this code because it would have crowded the message
<code> // COMMAND HEADER
if (rxMessage[0] != (byte)'J')
{
throw new InvalidDataException("Error: Invalid Command Header found");
}
// MCU TYPE
if (rxMessage[1] != (byte)DEVICE_ID)
{
throw new InvalidDataException("Error: Invalid Device ID");
}
|
|
|
|
|
Ok. i cant say i really understand your question, but rxMessage[2] is the 3'rd byte if that's what you're asking. MCU's are cool btw. i use AVR's alot
If it' stuck, DO NOT pull harder!
|
|
|
|
|
thats kwl thanx. The question was just to check that if i was in array[2] it would be containing three values.
So array.length should equal three or it is invalid so sure its right
|
|
|
|
|
just because you are accessing index 2 of the array it does not mean the length is three. If you can access index 2 without an array then there are at least 3 values.
what you should do is first check the length...
if(array.Length != 3)
then do your switch... I assume that index 3 tells what type of request it is and should always be present?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I am using a GridView on a page that will need to display data based on either a URL passed in with a QueryString OR fields passed from a form. This may return 50-500 records or so based on the state etc... If this is too many, (and only if this is too many) the user will be able to filter based on the occupation. I can get it to filter on query string AND state at the same time but not or sadly. I want it to default to all occupations after pulling from the DB based on state, (I tried setting the default value for occupation to -1) and then, the user can use the dropdown control to filter it more.
<asp:dropdownlist id="ddlCategories" runat="server" appenddatabounditems="True" autopostback="True"
datasourceid="sdsCategories" datatextfield="Occupation" datavaluefield="Occupation">
<asp:listitem text="All Categories" value="-1">
</asp:listitem>
</asp:dropdownlist>
<asp:sqldatasource id="sdsCategories" runat="server" connectionstring="<%$ ConnectionStrings:eventsConnectionString1 %>"
selectcommand="SELECT [Occupation] FROM [Events]" ProviderName="<%$ ConnectionStrings:eventsConnectionString1.ProviderName %>">
</asp:sqldatasource>
<asp:gridview id="gvProducts" runat="server" datasourceid="sdsProducts" style="margin-top: 12px;" AllowSorting="True" AutoGenerateColumns="False">
<columns>
<asp:BoundField DataField="EventTitle" HeaderText="EventTitle" SortExpression="EventTitle" />
<asp:BoundField DataField="EventEndDate" HeaderText="EventEndDate" SortExpression="EventEndDate" DataFormatString="{0:MM/dd/yyyy}" />
<asp:BoundField DataField="EventStartDate" HeaderText="EventStartDate" SortExpression="EventStartDate" DataFormatString="{0:MM/dd/yyyy}" />
<asp:BoundField DataField="EventCity" HeaderText="EventCity" SortExpression="EventCity" />
<asp:BoundField DataField="EventState" HeaderText="EventState" SortExpression="EventState" />
<asp:BoundField DataField="Occupation" HeaderText="Occupation" SortExpression="Occupation" />
</columns>
</asp:gridview>
<asp:sqldatasource id="sdsProducts" runat="server" connectionstring="<%$ ConnectionStrings:eventsConnectionString2 %>"
selectcommand="SELECT [EventTitle], [EventEndDate], [EventStartDate], [EventCity], [EventState], [Occupation] FROM [Events] WHERE ([EventState] = ?)" ProviderName="<%$ ConnectionStrings:eventsConnectionString2.ProviderName %>">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="PA" Name="EventState" QueryStringField="ID"
Type="String" />
</SelectParameters>
</asp:sqldatasource>
|
|
|
|
|
Hi all
maybe you can help me a little bit with COM component developed in C#.
I created one C# COM component to provide Excel with some functionality I needeed.
Everything was fine until I did some change to the assembly.
In the new version I did the following:
-I used the same GUID of the old version
-I used using the same strong key name of the old version
- I changed the Assembly version to 1.0.0.0 to 1.0.0.1.
- I registered the assebly in the global assembly cache with gacutil.
Since then Excel is not able to work anymore with this Com and doesn't recognize the library classes.
I tryed to cleanup of my system so I did:
-removal of the library from the GAC
-removal of the typelib
-reinstall of everything from scratch
at the end nothing improved!
What can I do to a perfect clean up of my system?
Some tool or some registry key or value to see?
Thanks in advance
ManuStone
|
|
|
|
|
On form load event i am loading dt Datatable obj from DB.
Setting Listbox control dataSource to dt, and respective display member, value member property. But its taking almost 2 sec,
If i do same for combobox control it takes hardly .1 sec
Why this behavior?
|
|
|
|
|
well it might help to see the code you have used for both methods.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
musefan wrote: well it might help to see the code you have used for both method
for combobox
Datatable dt = getTable();
cmb.DataSource = dt;
cmb.DisplayMember = "Name";
cmb.ValueMember = "Level";
for listbox
Datatable dt = getTable();
lst.DataSource = dt;
lst.DisplayMember = "Name";
lst.ValueMember = "Level";
On formLoad event.
this code i used, for cmb its fast, but for listbox its slow,
I am wondering why.........??
i am using c#. vs2003
regards,
|
|
|
|
|
Sorry, can't really offer a good answer.
To me it looks like you can't really do anything to help it yourself. I'm thinking maybe the comboBox and listBox handle DataSources differently and that is causing the delay - but I don't know that for sure.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I have a C function of format:
func1(double param[], int size);
This function is called from C# code the following syntax:
[DllImport("first.dll", EntryPoint = "func1", CallingConvention = CallingConvention.StdCall)]
public static extern int func1(ref double param[], int size);
The function 'func1' takes two parameters: the array in which values should be filled up from C dll and 'size' which tells the number of values to fill in the array.
Now if the param[] array is declared as param[] = new double[5]; and the 'size' parameter is given as 10, still the function passes.
Wherase the same scenario in direct C application, gives error saying "Array size(i.e. 5) is lesser than the number of values to fill(i.e. 10)".
I am not able to reproduce the same behavior in .Net. Can anybody help me with it?
|
|
|
|
|
My guess (I haven't checked) is that the number of bits used in C for the double may be 32, but in C# it's 64.
Hmmm, it appears that they are both 8 bytes (64 bit)
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
modified on Tuesday, June 30, 2009 9:36 AM
|
|
|
|
|
ok..how to ensure that both the sizes are the same..i mean if i declare array of size 5 (5 x 8 = 40bytes) should be the same in C# also.
|
|
|
|
|
I've just edited my previous reply as it appears that double is 8bytes (64 bits) in managed and unmanaged environments
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi Dave,
native float typically uses 4 bytes, and double doubles that, hence the name.
managed float always uses 4 bytes, and double 8 bytes.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Hi,
three remarks:
1.
shivapriyak wrote: public static extern int func1(ref double param[], int size);
I doubt you need the ref there. Objects (array is object) get passed by reference, so what you get is a pointer to the data anyway. With "ref" you get a pointer to a pointer, which you would then have to accept as a double**param.
2.
I typically don't rely on automatics marshaling, instead I use GCHandle class to pin the object and get its pointer into an IntPtr, then pass that to the native world. However, I am not saying your way could not work (without ref!).
3.
shivapriyak wrote: in direct C application, gives error saying "Array size(i.e. 5) is lesser than the number of values to fill(i.e. 10)".
How the heck can the function now that???
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
1. I have tried removing 'ref' and giving just double param[] in PInvoke...it didn't work
2. Tried using GCHandle class as below:
int func1(double param[],int size)
{
GCHandle handle = GCHandle.Alloc(param, GCHandleType.Pinned);
Pinvoke.func1(handle.AddrOfPinnedObject(),size);
}
The Pinvoke class is as:
[DllImport("myFile.dll",EntryPoint="func1",CallingConvention = CallingConvention.StdCall)]
public static extern int func1(IntPtr handle, int size);
But it didn't work...is this correct way? or do i need to tweak at some place.
Thanks,
Priya.
|
|
|
|
|
Hi,
shivapriyak wrote: it didn't work
that does not tell me much
shivapriyak wrote: int func1(double param[],int size)
{
GCHandle handle = GCHandle.Alloc(param, GCHandleType.Pinned);
Pinvoke.func1(handle.AddrOfPinnedObject(),size);
}
looks good, except when done you need to free the GCHandle.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Hello. I'm using SQLite and System.Data.SQLite.
If I create a new table, the file size is 2KB.
After insert 1000 records, the file size will be 34KB.
If I delete all record, the file size remain 34KB.
If I send SELECT command, the table is empty.
Why ?
Thanks.
|
|
|
|
|
stancrm wrote: Hello. I'm using SQLite and System.Data.SQLite.
If I create a new table, the file size is 2KB.
After insert 1000 records, the file size will be 34KB.
If I delete all record, the file size remain 34KB.
If I send SELECT command, the table is empty.
Why ?
Because a delete does not reclaim disk space (that would be a very wasteful use of system resources). Databases don't tend to allocate space as records are added, they allocate space in blocks and then insert records to the allocated space (it's much more efficient for them to do this as it results in less I/O activity on the disk).
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi,
you are getting an empty table because you deleted all records before. The file size of the database will not shrink if you delete rows because that would mean a reordering of the internal structure (db-records are stored in pages etc.). Some databases (especially for mobile applications) offer a shrink-command. This will result in the reordering and a smaller file.
At least: Please choose the correct forum for your question, I think "General Database" would be a better place.
Regards
Sebastian
|
|
|
|
|
Hi friend i am creating WindowDesktop application that will upload a large size of file to the server.
now when i upload file of small size its uploaded with no problem but when i upload large size of 62Mb or so it throw exception. can any body tell me that how can i upload large file and can i also pause uploading and resume Uploading feature
<pre
filestream="" stream="new" filestream("c:\\xyz.zip",="" filemode.open);
="" byte[]="" buffer="new" byte[stream.length];
="" int="" i="0;
" while="" ((i="stream.Read(buffer,0," buffer.length))>0)
="" {
="" ftpwebrequest="" request="(FtpWebRequest)FtpWebRequest.Create("ftp://ftp.abc.com/"" +="" path.getfilename("c:\\xyz.zip"));
="" try
="" {
="" request.method="WebRequestMethods.Ftp.UploadFile;
" request.credentials="new" networkcredential("demo123",="" "demo123");
="" request.usepassive="true;
" request.usebinary="true;
" request.keepalive="false;
"
="" request.timeout="int.MaxValue;
" reqstream="request.GetRequestStream();
" reqstream.write(buffer,="" 0,="" buffer.length);
="" reqstream.beginwrite(buffer,="" buffer.length,="" callback,="" "aa");
="" reqstream.close();
="" }
="" catch="" (exception="" ex)
="" stream.close();="">
i use both Write and BeginWrite method
WANTED wasim khan(Killed 50 Innocent Buggs, Distroyed 200 Exception, make 5 Project Hostage) any Compnay Hire him will pay 30,000. Best place where u can get him is Sorcim Technologies Murre Road RWP
|
|
|
|