|
Might sound like a silly question, but jeez it's really not obvious to make those toolstrips behave.
I'm really really interested in the solution too !
|
|
|
|
|
Hi,
I am working on an application that is able to read data from a keyboard wedged barcode scanner.
I want the barcode that is scanned to be displayed in a picture box in my form.
I use the code discribed in http://www.codeproject.com/KB/macros/BarcodeLibrary.aspx
to draw the barcode. Therefore I need 2 things :
1) the data to be encoded.
2) the type of the encoding (Code39, Code128, UPC A, UPC E, EAN13 etc..)
Since most barcode scanners are able to read several barcode types, is it possible to determine the type of the encoding the barcode reader uses to generate the data from a barcode image?
TIA
|
|
|
|
|
|
1. I created my own DLL in C++ (MyMathDll.dll), wrote a client program in c#. The program works on x86 system (32bit) but when i run it on x64 (64bit vista), I get the error, BadImageFormatException. It is simple function which adds two numbers as follows
int _cdecl Add(int x, int y)
{
return (x+y);
}
2. I have another problem with x86 windows. It is not able to load or even locate a particular dll. The dll was made with nmake utility? Could there be something wrong with the DLL. It locates other dlls fine. I verified this DLL in dumpbin and it looks good. Why it is not loadig?
|
|
|
|
|
I am making a project which contain several forms.
I want to access member id which r used in login, I want to use member id through mdi form on every form of project.
Please suggest me code if possible
Signature preview salil_k_singh
|
|
|
|
|
|
|
Hi there,
I'm having trouble understanding the usage of the merge function from DataSet objects.
Well, first I thought that it would only Add and Update existing rows from the target DataSet based on the new rows and modified rows in the source DataSet.
But for some reason my Merge function is actually deleting rows from the target wich are not in the source DataSet (this is EXACTLY what I want, I want it to DELETE rows too!)
My problem is that for some reason it is not deleting other rows, it just deletes a specific level.
Let me detail the context:
My dataset is composed by 3 levels (Clients -> Accounts -> Products).
When I merge DataSet1 with DataSet2 ( DataSet1.Merge(DataSet2, false) ) I want it to:
Add/Update Clients, Accounts and Products in DataSet1
AND
Delete Clients,Accounts and Products wich are not in DataSet2.
This DO happen in Products level, but NOT in Clients and Accounts level.
Any ideas on how to solve this problem?
For more information, please do ask.
Thanks
Oscar
|
|
|
|
|
Hi,
Maybe you have to make some changes on my code, but i wrote a merge myself.
static class DataSetMerging
{
public static bool ExtendedMerge(System.Data.DataSet Current, System.Data.DataSet Incoming, bool DeleteAbscent)
{
bool result = false;
if(Incoming != null)
{
foreach(System.Data.DataTable Table in Current.Tables)
{
System.Data.DataTable IncomingTable = Incoming.Tables[Table.TableName];
if(IncomingTable != null && Table.Columns.Count == IncomingTable.Columns.Count && Table.PrimaryKey.Length != 0)
{
int ctr = Table.Rows.Count-1;
while(ctr>-1)
{
System.Data.DataRow Row = Table.Rows[ctr];
object[] KeyValues = new object[Table.PrimaryKey.Length];
System.Data.DataColumn[] PrimaryKeys = new System.Data.DataColumn[Table.PrimaryKey.Length];
int ctr2 = 0;
while(ctr2<Table.PrimaryKey.Length)
{
KeyValues[ctr2] = Row[Table.PrimaryKey[ctr2]];
PrimaryKeys[ctr2] = IncomingTable.Columns[Table.PrimaryKey[ctr2].ColumnName];
ctr2++;
}
IncomingTable.PrimaryKey = PrimaryKeys;
System.Data.DataRow IncomingRow = IncomingTable.Rows.Find(KeyValues);
if(DeleteAbscent && IncomingRow == null)
{
Table.Rows.Remove(Row);
}
else if(IncomingRow != null)
{
bool UpdateRow = false;
int ctr3= 0;
while(ctr3<Table.Columns.Count)
{
if(Row[Table.Columns[ctr3].ColumnName].ToString() != IncomingRow[Table.Columns[ctr3].ColumnName].ToString())
{
UpdateRow = true;
Row[Table.Columns[ctr3].ColumnName] = IncomingRow[Table.Columns[ctr3].ColumnName];
}
ctr3++;
}
if(UpdateRow)
{
Row.AcceptChanges();
}
IncomingTable.Rows.Remove(IncomingRow);
}
ctr--;
}
if(IncomingTable.Rows.Count > 0)
Table.Merge(IncomingTable);
}
}
}
else
{
result = true;
}
return result;
}
}
Greetz
Kurt C.
|
|
|
|
|
Thanks a lot for your help Kurt!
Your code was successfully adapted to my application just by adding a check before updating rows
if (!dtbTabela.Columns[iContador3].ReadOnly)
{
UpdateRow = true;
Row[Table.Columns[ctr3].ColumnName] = IncomingRow[Table.Columns[ctr3].ColumnName];
}
I needed to do that because we have ReadOnly columns that are calculated based on the childs, this way by changing the childs it will automatically modify the parent.
What's pitty is that merging the datasets didn't improve the performance as we thought it would... but hey, sh*t happends.
I learned a lot from your code.
Thanks again!
Oscar
|
|
|
|
|
Feel up for a challenge?
This isn't homework (Don't worry :p)
Was doing some coding optimisations, when I thought up the following challenge:
Code:
static void Main(string[] args)
{
Stopwatch sw1 = new Stopwatch();
sw1.Start();
string shortString = "1234567890";
string largeString = "";
for (int j = 0; j < 50000; j++)
{
largeString += shortString;
}
if (largeString.Length == 500000)
{
Console.WriteLine("Pass 1");
}
else
{
Console.WriteLine("Fail 1");
}
if (sw1.ElapsedMilliseconds < 10000)
{
Console.WriteLine("Pass 2");
}
else
{
Console.WriteLine("Fail 2 - " + sw1.ElapsedMilliseconds);
}
Console.ReadLine();
}
Challenge:
Change ANY 2 lines of code ABOVE the
code line to display ONLY the following output
Pass 1
Pass 2
As it stands, this code snippet displays (On my PC):
Pass 1
Fail 2 - 38614
Hint: The speed of your computer (Should Be) Irrelevant...
Optimised, it took 211ms on my PC (Which is ALOT less than 10000)
Good Luck
-= Reelix =-
|
|
|
|
|
Any two lines above "// Touch Nothing Below Here"?
Easy ... only need to change one :P Move "sw1.Start();" to below the for loop
EDIT: And oh btw, your not calling stop on the stopwatch?
modified on Tuesday, May 20, 2008 11:44 AM
|
|
|
|
|
originSH wrote: Easy ... only need to change one Move "sw1.Start();" to below the for loop
Or, how about replacing the declaration of largeString...
string largeString = new string(' ', 500000);
...and then commenting out the concatenation in the loop.
It runs in 0.0006 seconds.
ssclaire
|
|
|
|
|
Or funny stuff like:
string largeString = new string(' ', 499990);
for (int j = 0; j < 1; j++)
and keep the inner loop untouched
modified 12-Sep-18 21:01pm.
|
|
|
|
|
The largeString variable doesn't even have to be a string, it only has to have a property named Length that returns the value 500000.
sw1.Start();
var largeString = new { Length = 500000 };
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
ROFL!
Never thought of that one
Congrats on the Unique Idea!
Your program will still take an insanely long time to finish, but hey :p
-= Reelix =-
|
|
|
|
|
Change Largestring to string builder and Append instead of concatenating...
Stopwatch sw1 = new Stopwatch();
sw1.Start();
string shortString = "1234567890";
StringBuilder largeString = new StringBuilder();
for (int j = 0; j < 50000; j++) {
largeString.Append(shortString);
}
if (largeString.Length == 500000) {
Console.WriteLine( "Pass 1" );
} else {
Console.WriteLine( "Fail 1" );
}
if (sw1.ElapsedMilliseconds < 10000) {
Console.WriteLine( "Pass 2" );
} else {
Console.WriteLine( "Fail 2 - " + sw1.ElapsedMilliseconds );
}
Console.ReadLine();
Pass 1
Pass 2
Keep DotNetting!!
GeekFromIndia
|
|
|
|
|
Thats the main answer I was looking for
string -> StringBuilder
Concat -> Append
Congrats :P
-= Reelix =-
|
|
|
|
|
oh..btw..it took just 29 ms on my machine after the change
Keep DotNetting!!
GeekFromIndia
|
|
|
|
|
for (StringBuilder b = new StringBuilder(); b.Length <= 500000; b.Length += 500000)
{
largeString += b.ToString();
}
Or am I missing something here? Takes exactly 2ms on my machine, and only 2 lines changed
Doing the StringBuilder stuff in a loop doesn't make much sense, but this way I could modify just 2 lines of code.
Pass 1
Pass 2 (2ms)
regards
modified on Tuesday, May 20, 2008 12:21 PM
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Heh... :p
Should have said the Loop-Line had to stay the same
Impressive Solution
-= Reelix =-
|
|
|
|
|
That's too easy. The obvious solution is to use a StringBuilder.
The real challange is to do it without using a StringBuilder.
And let's also test that the contents of the string is the same as with the original code:
bool pass = true;
for (int i = 0; i < 500000; i += 10) if (largeString.Substring(i, 10) != "1234567890") pass = false;
if (pass) {
Console.WriteLine("Pass 3");
} else {
Console.WriteLine("Fail 3");
}
Are you up for that?
I've got code that does it in 8 ms.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
Reelix wrote: And the (possible) answer YOU were looking for is one from further up...
Move the
sw1.Start();
JUST above the
// Touch Nothing Below Here
No, I have the sw1.Start(); at the top. No cheating.
Let's do it like this:
Stopwatch sw1 = new Stopwatch();
sw1.Start();
string largeString;
... code to populate the string here
if (largeString.Length == 500000) {
Console.WriteLine("Pass 1");
} else {
Console.WriteLine("Fail 1");
}
if (sw1.ElapsedMilliseconds < 1000) {
Console.WriteLine("Pass 2");
} else {
Console.WriteLine("Fail 2 - " + sw1.ElapsedMilliseconds);
}
bool pass = true;
for (int i = 0; i < 500000; i += 10) if (largeString.Substring(i, 10) != "1234567890") pass = false;
if (pass) {
Console.WriteLine("Pass 3");
} else {
Console.WriteLine("Fail 3");
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|