DdoubleD 315 Posting Shark

You didn't call your method. At line 19 you are writing out the abbreviation. Try:

Console.WriteLine("State is {0}", FromAbbreviation(abr));

In addition, you are already comparing to lower text switch(abr.ToLower().Trim()) at line 24, so all of those case labels you have for checking upper-case abbreviations will never test true--you can remove them.

DdoubleD 315 Posting Shark

To convert your byte[] to an image:

public static Image ByteArrayToImage(byte[] buffer)
        {
            using (MemoryStream ms = new MemoryStream(buffer))
            {
                System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
                return img;
            }
        }

or if cannot use Image.FromStream method (no CF support):

public static Image byteArrayToImage(byte[] byteArrayIn)
        {
            // Write the byte array to the memory stream
            MemoryStream ms = new MemoryStream(byteArrayIn);

            // Create a new bitmap object from the memory stream
            Bitmap bmp = new Bitmap(ms);

            // Finally, return the bitmap
            return bmp;
        }

then, assign it: pictureBox1.Image = ByteArrayToImage(blob1);

DdoubleD 315 Posting Shark

Take a look at the FileSystemWatcher component, which you can add to your form.

Here is a Daniweb snippet of its usage too:

http://www.daniweb.com/code/snippet217135.html

DdoubleD 315 Posting Shark

I am unaware of any .NET framework support for formatting your SD card, but you could call the SHFormatDrive Function from your app, which will invoke the Shell's Format dialog, presumably as a child window because it requires a valid HWND.

As far as reading and writing, unless you intend to perform direct access, I don't believe you need to do anything special except perhaps pay attention to the remaining space. Just use the System.IO's File and Stream I/O classes.

DdoubleD 315 Posting Shark

I'm not sure how your "web application" is deployed and you cannot simply access the file system on a client from a web service, but I won't make assumptions since you indicated you have "FCR" folders already setup on the clients. Try adding some exception handling around your file IO: FileStream Exceptions...

DdoubleD 315 Posting Shark

I don't use express version, but this looks like a nice step-by-step article for creating a database in Sql Express using VS: http://www.homeandlearn.co.uk/csharp/csharp_s12p2.html

DdoubleD 315 Posting Shark

Try this code. I modified your path construction to use backslash and added exception handling to provide specific error information.

string database = @"C:\Users\Jessie\Documents\Visual Studio 2008\Projects\Face\DAT\DTR_DB.s3db";
            string connParams = @"Data Source={0};Version=3;New=False;Compress=True;";
            string connStr = string.Format(connParams, database);
            SQLiteConnection conn = new SQLiteConnection(connStr);

            try
            {
                conn.Open();
            }
            catch (SQLiteException ex)
            {
                Console.WriteLine("Exception: {0}\r\n   Stack Trace: {1}", ex.Message, ex.StackTrace);
                System.Diagnostics.Debugger.Break();
            }
            finally
            {
                conn.Close();
            }
DdoubleD 315 Posting Shark

UPDATE tablename SET columnname1='value' WHERE columnname2='value';

If the value is numeric, leave off the ticks ('...') around the value.

DdoubleD 315 Posting Shark

You may also wish to consider this discussion of INI file interface and why you shouldn't use it.

DdoubleD 315 Posting Shark

You cannot assign a CR image path dynamically in vs 2005, but here is a work around you can use: http://dotnetfish.blogspot.com/2009/02/dynamic-image-in-crystal-report-9.html

DdoubleD 315 Posting Shark

As sknake pointed out, you would probably need to count the 872 lines by reading them in, but if you have lines that are fixed length, you could calculate the position within the stream ( lineLength * 872 ) and then use the Stream.Seek method to position the file pointer to the location you want to begin searching.

In addition, if you know each of these files will contain a certain block size (number of bytes) that you always want to skip, you could use the above to seek past that position. Furthermore, if you know that your search criteria will never be past a particular block size (number of bytes), you can evaluate the Stream.Position property to determine you have read past this point.

DdoubleD 315 Posting Shark

You can allow your user to select the file to open with OpenFileDialog..., then use XmlSerializer.Deserialize to read in your object(s). Once your object is loaded, just populate the form(s) with the read data. You might also want to see: Serialize method..., which you can use with your filename to save the object(s).

If having a particular problem with the above, just post or attach the code.

DdoubleD 315 Posting Shark

Not sure why you would ask this question rather than just test out your code to see if it does indeed work, but the code is nicely structured for the most part.

  • Your test for valid username/password will display a message box for every line read following the initial successful read of those two line items (username/password), but if those are the only two lines I suppose that wouldn't matter... You might consider having the method return a bool (success or not) that would allow the calling code to display message box and determine whether the user can continue in the program...
  • You might consider using a single configuration file for all users instead of a separate file for each... Also, naming the file same as username, then reading the line to compare the username is redundant.
  • Not sure you can use forward slash (eg. '/'), or single dot then slash (eg. "./" for relative) for the path portion of the string, but maybe it works?
  • You really should use encryption or another way to store/obscure the password (at a minimum) for obvious reasons.

If you are interested in improving the security and design, there are many articles and posts available here and elsewhere on the web.

DdoubleD 315 Posting Shark

You are driving down the road in your car on a wild, stormy night,
when you pass by a bus stop and you see three people waiting for the
bus:


1. An old lady who looks as if she is about to die.

2. An old friend who once saved your life.

3. The perfect partner you have been dreaming about.

Which one would you choose to offer a ride to, knowing that there
could only be one passenger in your car? Think before you continue
reading.

This is a moral/ethical dilemma that was once actually used as part
of a job application.

You could pick up the old lady, because she is
going to die, and thus you should save her first.

Or you could take the old friend because he once saved your life,
and this would be the perfect chance to pay him back.

However, you may never be able to find your perfect mate again.


YOU WON'T BELIEVE THIS.....................

The candidate who was hired (out of 200 applicants) had no trouble
coming up with his answer. He simply answered: 'I would give the car keys
to my old friend and let him take the lady to the hospital. I
would stay behind and wait for the bus with the partner of my dreams.'


Sometimes, we gain more if we …

Antenka commented: hehe .. nice finish :D +0
William Hemsworth commented: great one :) +0
DdoubleD 315 Posting Shark

Turns out to have been related to the suggested link after all. Missing Write permission on %USERPROFILE%\temp folder for group account "Users". Thanks.

DdoubleD 315 Posting Shark

What happens when you run it outside the application from a command prompt? Does it create a log file? Does it create any Event Log entries?

What are the errors it returns?

DdoubleD 315 Posting Shark

Hi!,

I think your account doesn’t have enough privileges to create the ldb file. Please have a look at this link - http://support.microsoft.com/kb/251254/en-us

Thanks for the reply. I verified the information on the link and that does not appear to be the problem because I am Admin and both the TEMP and TMP settings are defined, exist, and are accessible.

I am able to connect my Access db within my code, just cannot get the Report Wizard to connect.

DdoubleD 315 Posting Shark

Hi. I decided to try out the Report Wizard, having only worked with Crystal Reports prior, and when I try to connect to an Access DB with the default OLE DB data provider, I get "Unspecified Error" in the Add Connection dialog upon "Test Connection" or trying to accept the selection.

Any ideas?

DdoubleD 315 Posting Shark
DdoubleD 315 Posting Shark
DdoubleD 315 Posting Shark

EDIT: Scratched response... Please see: http://msdn.microsoft.com/en-us/library/s35hcfh7(VS.71).aspx

DdoubleD 315 Posting Shark

Your email address was removed because forum protocol prohibits it. Take a look at this MSDN example: SmtpClient example...

DdoubleD 315 Posting Shark
DdoubleD 315 Posting Shark
DdoubleD 315 Posting Shark

I don't see a Delete command from your code sample. See: http://msdn.microsoft.com/en-us/library/bb177896.aspx

DdoubleD 315 Posting Shark

What you want is INSERT INTO ... VALUES(...): http://msdn.microsoft.com/en-us/library/bb208861.aspx, because the INSERT INTO ... SELECT FROM inserts fields FROM another table and you want to insert your TextBox.Text VALUES into your table.

It is unclear to me why you have what appears to be mixture of controls and control Text (eg. "rentaltb.Text", but "daystb") when they both appear to be named as though they are both TextBox controls ("tb" designation), but you don't reference the Text property in both places. Perhaps the latter is actually a string and not really a TextBox ...

DdoubleD 315 Posting Shark

I didn't see where there was any change to this method for Windows 7. Perhaps you want the SaveFileDialog flexibility: http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog.aspx

You can set the InitialDirectory to be whatever drive:path concerns your application.

DdoubleD 315 Posting Shark

Here is another way that loops through the forms control collection to find the given control by it's name and passing in the form's control collection ( this.Controls ) since you already added it to the collection ( this.Controls.Add ):

public static bool EnableControl(System.Windows.Forms.Control.ControlCollection controls, string name, bool enable) 
            {
                foreach (Control c in controls)
                {
                    if (c.Name == name)
                    {
                        c.Enabled = enable;
                        return true; // found it...
                    }

                    // search child controls too...
                    if (EnableControl(c.Controls, name, enable))
                        return true;
                }
                return false; // control not found...
            }

In the above, you would call the method using your constructed button name: eg, "But2up"... using button name also the same for next example...

Another way is direct access (via control's Name ) if not a child control...:

this.Controls[name].Enabled = false;

If speed is a concern/problem, you should stick with sknake's example as the Dictionary approach will contain a much smaller list than that of the Form's control collection depending on the number of other controls you have within the form (in the collection).;)

DdoubleD 315 Posting Shark

It looks like you are creating a new row, but you are calling Update (missing UpdateCommand though too for that): http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbdataadapter.updatecommand(VS.71).aspx

For inserting a new row, you need to specifiy an InsertCommand: http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbdataadapter.insertcommand(VS.71).aspx

DdoubleD 315 Posting Shark

You have indicated you are getting a "null reference" error, and you have provided a snippet that does not reveal the cause of the error; unless it is because "em" has not been instantiated. I suggest you zip up the project and attach it with data. If you cannot do that, at the very least you need to indicate which line causes the error so we can direct you to the possible cause.

EDIT: Just saw ddanbe replied with the same suspicion related to "em"...

DdoubleD 315 Posting Shark

You might want to check into the MS reference source server for the latest source available for VS 2008. You must follow all of the instructions. It will add some overhead to the start of your debug session, but once you are satisfied with the code already downloaded to your local cache, you can disable the search option to improve performance (Tools/Debugging/Symbols): http://referencesource.microsoft.com/

Once configured, you will be able to step into the .NET source code.

DdoubleD 315 Posting Shark

After rereading your post, it occurs to me that adatapost has probably hit more on what you are asking for. Just combine the control iteration examples with his "common" event wiring example and you have your answer.

DdoubleD 315 Posting Shark

thanks very much
the compiler give me a message
The name 'FindControlsOfType' does not exist in the current context

Sorry about that. I just realized that I had copied those methods from somewhere into a code file I have. I searched the forum to see if I found them here, but I got no matches. Anyway, I'm going to repost them since I can't locate the link to direct you too, but it's pretty straight-forward stuff that also uses recursion to search child controls:

public List<Control> ListControlsOfType(Control ctrl, Type t)
            {
                List<Control> ctrlList = new List<Control>();
                foreach (Control c in ctrl.Controls)
                {
                    // add this control if of type specified...
                    if ((c.GetType() == t) || c.GetType().IsSubclassOf(t))
                        ctrlList.Add(c);

                    // search and add all child controls too...
                    foreach (Control childCtrl in c.Controls)
                        ctrlList.AddRange(ListControlsOfType(childCtrl, t));
                }
                return ctrlList;
            }

            // use ListControlsOfType instead!!!
            public Array FindControlsOfType(Control ctrl, Type t)
            {
                System.Collections.ArrayList result = new System.Collections.ArrayList();
                foreach (Control c in ctrl.Controls)
                {
                    if ((c.GetType() == t) || c.GetType().IsSubclassOf(t))
                        result.Add(c);
                    foreach (Control childCtrl in c.Controls)
                        result.AddRange(FindControlsOfType(childCtrl, t));
                }
                return result.ToArray(t);
            }

EDIT: To whomever wrote those methods, my apologies for not giving you credit.:$

DdoubleD 315 Posting Shark

I don't see where you are setting up the update command... Look at this link: http://msdn.microsoft.com/en-us/library/system.data.common.dataadapter.update.aspx

DdoubleD 315 Posting Shark
Button[] btnsAry = (Button[])FindControlsOfType(/*this*/ form1, typeof(Button));
                foreach (Button btn in btnsAry)
                    btn.BackColor = Color.Red;

Or, you could use a list (List<>):

List<Control> btnList = ListControlsOfType(/*this*/ form1, typeof(Button));
                foreach (Button btn in btnList)
                    btn.BackColor = Color.Red;
DdoubleD 315 Posting Shark

You cannot simply estimate time based on samples and, as I am sure you are aware, no progress for downloading from the web is extremely accurate. Given that is true all around, user's expect there to be plus/minus whatever they have experienced... In light of this, the best you can do is attempt to recalculate the download time at intervals based on the current sampling of progress...

Here are some links you might find useful:

http://stackoverflow.com/questions/1587333/c-calculate-download-upload-time-using-network-bandwidth
http://stackoverflow.com/questions/933242/smart-progress-bar-eta-computation
http://forums.asp.net/p/1438079/3280750.aspx#3280750

Also note that since the BackGroundWorker will only update when it receives a slice of CPU time, the thread might not be processing in exact increments.

DdoubleD 315 Posting Shark

First, change this post to NOT be a snippet because that is not what a SNIPPET is for!

Where it asks for "What are you posting?", just use the default: Forum Thread

DdoubleD 315 Posting Shark

Post the code in question, or zip up the project so we can see what is happening.

DdoubleD 315 Posting Shark

That's my bad as I counted wrong :P
After applying that line it still gives 0 as returnvalue :(

First, check to see you saw my edits cause I made a couple.;)

Second, compare data:

Id comboId itemId itemId1
3 1 1 3
5 5 1 2
7 4 1 2
10 6 1 2
13 8 1 4


In the above, I have 3 matching records because "Hout" matches itemId in Items_1 and "Steen" matches itemId1 from Items_2...

In the middle where ItemId = 1 and itemId1 = 2 there are three records..

DdoubleD 315 Posting Shark

When I test I set item1 to Hout and item2 to Steen
That combination exists twice so.....

FYI: That combination exists 3 times in my data...

DdoubleD 315 Posting Shark

LOL... Still some holes in your answer, but I think this might be closer to what you want:

string select3 = "SELECT Count(*) FROM Combineren "
                    + "WHERE itemId1 "
                    + "IN (SELECT itemId1 FROM Items_2 WHERE Naam = '" + naam2 + "' ) "
                    + "AND ItemId "
                    + "IN (SELECT itemId FROM Items_1 WHERE Naam = '" + naam1 + "') ";

This gives me a count of 3 for naam1 = "Hout" and naam2 = "Steen".

DdoubleD 315 Posting Shark

When I test I set item1 to Hout and item2 to Steen
That combination exists twice so.....

You are going to have to explain what it is that you are wanting to compare exactly because I couldn't decipher a match based on the example SQL string you supplied given the data I have from the downloaded attachment...

Are you wanting to compare cominaren where the itemid matches the records with naam having a match in Item_1.itemid and also a match on Combinaren.itemid1 in Item_2.itemId1? None of these will ever match given the data I have because the Items_1 and Items_2 table are exactly the same, but the id fields in the cominaren table don't seem to correspond to these...

DdoubleD 315 Posting Shark

When I use this code it constantly returns with 0 :S
Any idea why?

I tested it with naam='Hout' because those were the only records in the Combineran table where itemId had a match because they are all set to '1' (itemId=1), which matches 'Hout' from the other two tables...

Returns 5 because there are 5 records with that id in the Combineran table.

DdoubleD 315 Posting Shark

Try this:

System.Windows.Input.MouseEventArgs ee = (System.Windows.Input.MouseEventArgs)e;
DdoubleD 315 Posting Shark

What will the code look like if I want to use something similar to this:

string SQLString = "SELECT Count(*) FROM Combineren WHERE Items_1.itemId=Combineren.itemId AND Items_2.itemId1=Combineren.itemId1 AND Items_1.Naam = '" + item1 + "' AND Items_2.Naam = '" + item2 + "'";

This piece gives the error of missing parameters.

Try this:

string select2 = "SELECT Count(*) FROM Combineren "
                    + "WHERE itemId "
                    + "IN (SELECT itemId1 FROM Items_2 WHERE Naam = '" + naam + "' ) "
                    + "AND ItemId "
                    + "IN (SELECT itemId FROM Items_1 WHERE Naam = '" + naam + "') ";
DdoubleD 315 Posting Shark

Just add the cast explicitly:

MouseEventArgs ee = (MouseEventArgs)e;
DdoubleD 315 Posting Shark

Maybe someone in here will know LISP, but you would probably get a much faster response if you translate the above LISP code into pseudo code first, then we can translate that into C# code.

DdoubleD 315 Posting Shark

Unfortunately, I don't think there a simple answer to this problem. I ran into this thread where a number of people reported problems and a "wild goose chase" ensued trying to pinpoint the problem. So, the thread is quite lengthy, but if you take the time to read through it, you might, hopefully, identify something that is relevant to your application's deployment:
ClickOnce-deployed application failure...

DdoubleD 315 Posting Shark

Here is a link that shows you how to execute an update command on the table: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.updatecommand.aspx

DdoubleD 315 Posting Shark

Hi, this image could help.

I also tried to register the functions.dll with the gac, but it still not working.

Thanks

It sounds like the plugin is expecting the functions.dll to be in the entry-assembly's path. How is the plugin referencing this dll? I assume you have the build for the plugin too since both the app and the plugin references it? Have you looked into the Assembly.LoadFrom method: http://msdn.microsoft.com/en-us/library/1009fa28.aspx?