|
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
|
|
|
|
|
We cannot know unless you tell us what Expetion you are getting
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi Vuyiswa Maseko
Error is "Unable to write data to the transport connection: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full."
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
|
|
|
|
|
musefan is Right increase the Buffer and see what happends
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I'm actually suggesting to reduce the buffer size.. but I assume that is what you meant anyway
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Its one of those Days
today its the Final day of my Project
Am tired
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I see
Just out of interested what is your project? is it a course project?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
|
Interesting
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I have not really read your code but my first guess would be your buffer array size is causing the issue. The buffer should not contain all the data else you may as well use the stream itself.
Try a buffer size of 1024 - that's a common size that is used.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
yes i set the buffer size to 1024
it working but in process it threw exception couple of time "The underlying connection was closed: An unexpected error occurred on a receive."
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
|
|
|
|
|
Try creating the response stream (and closing it) outside of the while loop then just write the buffer contents in each loop.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|