DdoubleD 315 Posting Shark

I'm not sure if there is a typo in your format example because that seems rather large, but have you looked into controlling the NumberFormat property? See: http://msdn.microsoft.com/en-us/library/aa224873(office.11).aspx

It is supposed to allow you the same flexibility as the number properties formatter in Excel.

DdoubleD 315 Posting Shark

You can move the caret position in a textbox using TextBox.Select(...) . Just set the start parameter to the desired location of the caret and set length param to 0 or 1 (can't remember exactly if length needs to be 1). See: http://msdn.microsoft.com/en-us/library/system.windows.controls.textbox.select.aspx

DdoubleD 315 Posting Shark

Hi emclomdon,

For your "Input string was not in a correct format" error, consider using double.TryParse(...) , which will allow you to catch null/invalid values and assign them accordingly as zero. Also consider assigning default values and filtering the input if you have not already.

For your DateTimePicker, the MinDate and MaxDate properties are supposed to limit the min and max selectable dates, so I am unsure why you are not getting the desired result. Look at this usage example and see if you can spot your problem: http://msdn.microsoft.com/en-us/library/system.windows.forms.datetimepicker.mindate.aspx

DdoubleD 315 Posting Shark

You may wish to consider modifying your C++ program to find the file relative to where its exe/process is running, or setting the full pathname of the exe in your process call (exact issue is unclear to me), but look at changing the current working directory as a possible fix for your dilemma: http://msdn.microsoft.com/en-us/library/system.environment.currentdirectory.aspx

DdoubleD 315 Posting Shark

Here is a rough example that attempts to do what you have asked for. I expect it will not meet all of your needs, but hopefully it will serve as a good starting example of how you can translate your logic to manipulate the read in data and achieve the desired result in C#. As Ryshad pointed out, "regular expressions" is very robust and highly recommended because of that, but it can also create efficiency concerns and the learning curve is somewhat steep--it really depends on the complexity of whatever you are doing.

public static void Test()
        {
            List<string> values = BuildListBoxValues("abcd fdsag\0dkeowsloiekdlss saasfdasfd 098098", "qwertyuiopasdfghjklzxcvbnm", 5, 10);

            listBox1.Items.Clear(); // clear existing ListBox items...

            // add each acceptable string that was found to the ListBox...
            foreach (string value in values)
                listBox1.Items.Add(value);
        }

        public static List<string> BuildListBoxValues(string data, string charsAllowed, int minLength, int maxLength)
        {
            // List of acceptable strings we will return (to be used for ListBox)...
            List<string> values = new List<string>();
            int ndx = 0;

            // process entire length of data string...
            while (ndx < data.Length)
            {
                char c = data[ndx]; // get first character for loop below...
                string value = "";  // reinitialize our acceptable ListBox value holder...

                // build string value for addition to List<string>, checking each allowed character...
                while (charsAllowed.Contains(c))
                {
                    value += c; // append the allowed character...
                    ndx++;      // increment for next character check...
                    c = data[ndx]; // get next character...
                }

                // Does the string value meet our length criteria?
                if (value.Length …
DdoubleD 315 Posting Shark

Are you getting a deadlock condition? Try adding proc.WaitForExit() following your call to reader.ReadToEnd() .

More information at:
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput.aspx

DdoubleD 315 Posting Shark

Hi ernst1234,

Here are some more tips for you to get moving on this assignment:

* You will want to measure the size of the string in the label and resize the width of the label control to ensure the text does not exceed the window region: Graphics.MeasureString

* Then, you can use the above to adjust the Label.Size * As ddanbe already mentioned, you can move the label by changing the Label.Location property inside a loop (don't forget to call label.Refresh() method afterwards).

* To control the delay in the loop, check out this.Thread.Sleep(...) * As far as the delegate is concerned, that's just a type that references a method, and you just need to determine when and what method you will call. See: Delegates

DdoubleD 315 Posting Shark

This appears to have accomplished what I requested--very cool! Let me mull this over tomorrow and I will get back to you. Thanks again for showing me how this can be done using LINQ!

EDIT >>> Actually, this was more straightforward than I thought. If I have understood correctly, all I need in this case to apply a criteria of a particular powerball number is this modification (hardcoded powerball number of 2):

var firstQuery = from DataRow dr in dt.Rows
                                 where int.Parse(dr["PB"].ToString()) == 2
                                 select int.Parse(dr["WB" + i.ToString()].ToString());

If I have understood correctly enough, I will mark this thread as solved and just create a new thread if I have additional questions... Let me know and thanks!

DdoubleD 315 Posting Shark

apegram, thanks for your help! I believe the query you gave is partitioning the projection into the top 10 ball counts for each column ("WB1" THRU "WB5"). However, what I am looking for is a query statement that would partition the top 10 accumulated ball count "across all five columns". I'm not sure if I have worded that coherently enough for you to interpret...

Let us say that "WB1" contains 37 instances of ball number 2 and each of the remaining columns ("WB2" THRU "WB5") contain only 2 instances of ball number 2. When determining the top 10 ball counts, I want to evaluate 45 instances of ball 2 and not just 37; where 37 is a high (top 10) count in column "WB1" only. Does that make sense? Also, these counts I'm throwing out are arbitrary and not real. Here is what I am using to tally the actual ball instances for comparison:

int[] wb = new int[MAX_WB];
        int[] pb = new int[MAX_PB];
        int[] pp = new int[MAX_PP];

        public void TallyPicks(DateTime dateStart, DateTime dateEnd)
        {
            Array.Clear(wb, 0, wb.Count());
            Array.Clear(pb, 0, pb.Count());
            Array.Clear(pp, 0, pp.Count());
                
            try
            {
                string query = "DrawDate >= '" + dateStart.Date + "'"
                    + " AND DrawDate <= '" +dateEnd.Date + "'";
                
                if (PowerBall > -1)
                    query += " AND PB = " + PowerBall;

                DataRow[] rows = dt.Select(query);
                //for (int i = 0; i < dt.Rows.Count; i++)
                for (int i=0; i<rows.Count(); i++)
                {
                    //DataRow dr = dt.Rows[i];
                    DataRow dr = rows[i];

                    //System.Diagnostics.Debug.Assert(dr.ItemArray.Count() == …
DdoubleD 315 Posting Shark

Hello friends! I've been playing around with the MS Chart class type (System.Windows.Forms.DataVisualization.Charting) and have a situation where I would like to know how to code a query of my data using LINQ. The data I'm playing with is the PowerBall drawings data that is updated each drawing: http://www.powerball.com/powerball/winnums-text.txt

I'm loading a DataTable from the file above:

public const int MAX_WB = 59;
        public const int MAX_PB = 42; // only 39 now, but must have been upto 42 at one time???
        public const int MAX_PP = 5;

        public void LoadData(string filename)
        {
            try
            {
                //first make sure the file exists
                if (!File.Exists(filename))
                {
                    throw new FileNotFoundException("The file " + filename + " could not be found");
                }

                //create a StreamReader and open our text file
                using (StreamReader reader = new StreamReader(filename))
                {
                    Filename = filename;

                    // Using DataSet; structure same as commented code below...
                    dt = dsPowerBall.Tables["Drawings"];
#if false
                    // Add data columns
                    dt.Columns.Add(new DataColumn("DrawDate", typeof(DateTime)));
                    dt.Columns.Add(new DataColumn("WB1", typeof(int)));
                    dt.Columns.Add(new DataColumn("WB2", typeof(int)));
                    dt.Columns.Add(new DataColumn("WB3", typeof(int)));
                    dt.Columns.Add(new DataColumn("WB4", typeof(int)));
                    dt.Columns.Add(new DataColumn("WB5", typeof(int)));
                    dt.Columns.Add(new DataColumn("PB", typeof(int)));
                    dt.Columns.Add(new DataColumn("PP", typeof(int)));
#endif
                    dt.Rows.Clear();
                    string data = reader.ReadToEnd();
                    string[] rows = data.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    
                    // skip first row of data containing the column names
                    for (int i=1; i<rows.Count(); i++)
                    {
                        bool error = false;

                        string r = rows[i];

                        string[] values = r.Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);

                        // scrub data...
                        if (values.Count() < 7)
                            error = true;

                        DateTime date = (DateTime)Convert.ToDateTime(values[0]);
                        int wb1 = (int)Convert.ToInt32(values[1]);
                        int wb2 = (int)Convert.ToInt32(values[2]);
                        int wb3 = (int)Convert.ToInt32(values[3]); …
DdoubleD 315 Posting Shark

Back to where we started... You are correct that the DsoFile library does not support the "Hyperlink base" property. I tried to find the source code for this library, but it appears to no longer be available.

However, I did determine the reason for the original failure is due to automation client not realizing that a change has been made to the document and then, subsequently and apparently, ignoring the forced call to the _Document.Save() . I could not find a flag to manually set to indicate a change was made, so I added a modification to the document's content, followed by a call to undo the changes:

// Make a modification to the document because property changes don't 
                // seem to get recognized as changes and are thus ignored even when calling Save().
                doc.Content.InsertBefore("Temporary change...\r\n");
                // Undo the change above...
                doc.Undo(ref oMissing);

Now, the document will actually get saved with the desired property modifcations. Here is a working example-method to demonstrate this:

public static void ChangeHyperlinkBase(string docFilename, string hyperlink)
        {
            Word.Application wordApp;
            Word._Document doc;
            object oMissing = System.Reflection.Missing.Value;

            //Create an instance of Microsoft Word and make it visible.
            wordApp = new Word.Application();
            wordApp.Visible = false;

            try
            {
                object oFilename = docFilename;
                object ro = false;
                doc = wordApp.Documents.Open(
                    ref oFilename,
                    ref oMissing, ref ro, ref oMissing,
                    ref oMissing, ref oMissing, ref oMissing,
                    ref oMissing, ref oMissing, ref oMissing,
                    ref oMissing, ref oMissing, ref oMissing,
                    ref oMissing, ref oMissing, ref oMissing);

                object oDocBuiltInProps = doc.BuiltInDocumentProperties;
                Type typeDocBuiltInProps …
DdoubleD 315 Posting Shark

An honest politician, a kind lawyer and Santa Claus walked through a very posh hotel lobby. There, in front of them, was a $100 Dollar bill lying on the floor. Which one picked it up?

!tsixe t'nod owt rehto eht ,esruoc fo atnaS

!eno taht no hgual em ekam did uoy tub ,krow em edam uoy ,KO

DdoubleD 315 Posting Shark

I believe I understand what you want, and I don't think it is possible with user control. I have also wanted to create custom controls utilizing UserControl without the need to manually expose each of the methods and properties of the container controls. If and when you figure it out, please share.;)

DdoubleD 315 Posting Shark

Here is an example of how you implement the BackgroundWorker instead of trying to implement the ProgressBar independently. If you use this technique, avoid using the PerformStep() altogether (even though it is possible to do).

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            // Number of items to process in our loop...
            const int total = 137;

            for (int i = 0; i < total; i++)
            {
                // check cancellation flag. See documentation for multi-threading remarks!!!
                if ((worker.CancellationPending == true))
                {
                    e.Cancel = true;

                    // Optional: Set a result that can be accessed in RunWorkCompleted event...
                    e.Result = "Work haulted; failure ocurred...";

                    return;
                }
                else
                {
                    // Simulate some processing time....
                    System.Threading.Thread.Sleep(50);

                    // calculate progress...
                    int pct = (int)((i + 1.0) / total * 100);

                    // verify calculation....
                    Console.WriteLine(pct);

                    // Update the progress bar...
                    worker.ReportProgress(pct);
                }
            }
            // Optional: Set a result that can be accessed in RunWorkCompleted event...
            e.Result = "Work completed; no errors encountered...";
        }

        // using ProgressPercentage...
        private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            // Set the current progress value and update the control...
            progressBar1.Value = e.ProgressPercentage;
            progressBar1.Update();
        }

        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            string msg;

            if (e.Cancelled == true)
            {
                // Use message we passed in 'Result'...
                if (e.Result != null)
                    msg = (string)e.Result;
                
                else
                    msg = "Canceled; Reason unknown!";
            }

            else if (e.Error != null)
                msg = ("Error: " + e.Error.Message);
            
            else
                msg = "Done!";
            

            MessageBox.Show(msg);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Cannot set …
DdoubleD 315 Posting Shark

the error is

System.Data.SQLite.SQLiteException: File open is not a database file file is encrypted or not a database ...

I thought I already replied to this... It sounds like you might have a compatibility issue between the DB and the client data provider. If you think this might be the case, you should verify the versions are compatible.

DdoubleD 315 Posting Shark

Could i be you need more something like this? http://en.wikipedia.org/wiki/555_timer_IC
You could set this on and off via C#.

Now that makes sense to me because I would think you would use a dedicated circuit/processor for that kind of speed. I had no idea those 555 timers are still so popular. I have built some fun stuff with them way-back-when (decibel meter, strobing LED's, binary clock).;)

DdoubleD 315 Posting Shark

I'm going to break protocol here somewhat, perhaps (since the question has already been begged), and ask what kind of scenario you are wanting to manipulate with a timer in microseconds? My teeny-macro mind cannot fathom what it could be...:icon_redface: Any real-world explanation would suffice for me if you cannot divulge the actual purpose.

DdoubleD 315 Posting Shark

Also take a gander at this similar discussion for other techniques for accomplishing your goal: http://www.daniweb.com/forums/thread241075.html

DdoubleD 315 Posting Shark

Yes, for example:

public class class1
        {
            public static int GetCustomerID(string lastname, string firstname)
            {
                int id = -1;
                // TODO: db query here...

                return id;
            }
        }
        public partial class Form1 : Form
        {
            TextBox textBox1 = new TextBox(); // I put here for reference only...
            TextBox textBox2 = new TextBox(); // I put here for reference only...
            //...

            private void GetCustomerID()
            {
                string lastname = textBox1.Text;
                string firstname = textBox2.Text;
                int customerId = class1.GetCustomerID(lastname, firstname);
            }
        }

Now, I suspect the answer you are looking for requires more information, but maybe not... Please elaborate if this is not a sufficient answer.

DdoubleD 315 Posting Shark

Given the code sample and question, you only need to declare the methods static within a class and you can reference/call them anywhere as long as you establish a reference within your project and call the method by it's fully qualified name. For example:

namespace MyNameSpace
{
    public class MyMathMethods
    {
        public static void MyMethod1()
        {
            Console.WriteLine("doing something in MyMathMethods.MyMethod1()...");
        }
        public static void MyMethod2()
        {
            Console.WriteLine("doing something in MyMathMethods.MyMethod2()...");
            string s = MyStringMethods.MyMethod1();
            Console.WriteLine("call to MyStringMethods.MyMethod1() returned: " + s);
        }
    }
    public class MyStringMethods
    {
        public static string MyMethod1()
        {
            return "MyStringMethods.MyMethod1() called...";
        }
        public static string MyMethod2()
        {
            return "MyStringMethods.MyMethod2() called...";
        }
    }
}

You could define these in different namepace's within the same file too (this is NOT typical way to organize namespaces, but perfectly legal):

namespace MyMathNamespace
{
    public class MyMathMethods
    {
        public static void MyMethod1()
        {
            Console.WriteLine("doing something in MyMathMethods.MyMethod1()...");
        }
        public static void MyMethod2()
        {
            Console.WriteLine("doing something in MyMathMethods.MyMethod2()...");
            string s = MyStringNamespace.MyStringMethods.MyMethod1();
            Console.WriteLine("call to MyStringNamespace.MyStringMethods.MyMethod1() returned: " + s);
        }
    }
}
namespace MyStringNamespace
{
    public class MyStringMethods
    {
        public static string MyMethod1()
        {
            return "MyStringMethods.MyMethod1() called...";
        }
        public static string MyMethod2()
        {
            return "MyStringMethods.MyMethod2() called...";
        }
    }
}

And, if you wanted to separate them (namespaces) into separate files (this IS typical way to organize namespaces):

// in MyMathNamespace.cs file
namespace MyMathNamespace
{
    public class MyMathMethods
    {
        public static void MyMethod1()
        {
            Console.WriteLine("doing something in MyMathMethods.MyMethod1()...");
        }
        public static void MyMethod2()
        {
            Console.WriteLine("doing something in MyMathMethods.MyMethod2()...");
            string s …
DdoubleD 315 Posting Shark

You could synchronize the 2nd WebBrowser's loaded page using the webBrowser1_Navigated event handler:

private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            if (bSychronize)
            {
                if (webBrowser1.Url.ToString() != webBrowser2.Url.ToString())
                    webBrowser2.Navigate(e.Url.ToString());
            }
        }

In the above, the boolean bSynchronize can be toggled by a button click event:

private void button1_Click(object sender, EventArgs e)
        {
            bSychronize = !bSychronize;
        }
DdoubleD 315 Posting Shark

As ddanbe said, and you can use the FindItemWithText method to retrieve the corresponding item:

private void SetReservation(string time, string reservation)
        {
            // find item with matching time...
            ListViewItem item = listView1.FindItemWithText(time);
            if (item != null)
            {
                // Set value for reservation column...
                item.SubItems[1].Text = reservation;
            }
        }
ddanbe commented: He! did not know that. Thanks :) +6
DdoubleD 315 Posting Shark

If it is a rectangle you want to move/draw, you can call the Graphics.FillRectangle method in the OnPaint :

private void panel1_Paint2(object sender, PaintEventArgs e)
        {
            e.Graphics.FillRectangle(Brushes.Red, rect);
        }

For the above Rectangle , I created a class variable called rect :

Rectangle rect = new Rectangle(0, 0, 20, 20);

Then, all you need to do is call a method similar to the snippet of code you posted, passing the parameters/coordinates as arguments:

private void MoveRectangle(int x, int y, int width, int height)
        {
            rect.X = x;
            rect.Y = y;
            rect.Width = width;
            rect.Height = height;
            panel1.Refresh();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 30; i++)
            {
                MoveRectangle(i * 3, 0, 20, 20);
                Thread.Sleep(200);
            }        
        }

The above will move a small red-square horizontally.

DdoubleD 315 Posting Shark

What is it you want to do with your panel? Here is an example that draws some text whenever it is repainted, and the form has a button to change the 'value' of the text:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace ForumSolutions
{
    public partial class Form_Panel : Form
    {
        string text = "Merry Christmas!";

        public Form_Panel()
        {
            InitializeComponent();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawString(text, ((Panel)sender).Font, new SolidBrush(Color.Red), e.ClipRectangle);
        }

        private void Form_Panel_Load(object sender, EventArgs e)
        {
            // force the panel to redraw....
            panel1.Refresh();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            text = "Happy New Year!";
            panel1.Refresh();
        }
    }
}
DdoubleD 315 Posting Shark

Please refer to this example, which demonstrates (*.txt), but you can modify according to your needs: http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx

DdoubleD 315 Posting Shark

You might refer to this similar discussion to see if it helps you: http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/aa8c9bde-5cb5-44e4-b9e2-7608470ce08e/

DdoubleD 315 Posting Shark

I believe you are referring to Jan Dolinay's "Detecting USB Drive Removal in a C# Program"? This is not part of the .NET framework to my knowledge. In addition, the CodeProject download contains only the DriveDetector.cs file, which defines the Donlinay namespace; so there probably is not an external library your project needs...

All you need to do is add this file to your project. If you have lost it, just download it again, then add it to your project: http://www.codeproject.com/KB/system/DriveDetector.aspx

DdoubleD 315 Posting Shark

Here is an example I put together that creates a table with background image using HTML. The HTML is inline and does not import a CSS file--sorry. I'm no expert in the subject, but wouldn't the import be performed by the client (browser, outlook, etc.) and not gmail, thus eliminating gmail as the cause of any limitation? Otherwise, I suppose you should generate the HTML from the style sheet during the construction of the html body...

public static bool SendMailHtml()
        {
            try
            {
                using (MailMessage mail = new MailMessage())
                {
                    // who is sending message...
                    mail.From = new MailAddress(addressFrom, nameFrom);

                    // add as many recipients as needed...
                    mail.To.Add(new MailAddress(addressTo, nameTo));

                    // subject of message...
                    mail.Subject = "Subject text goes here...";

                    // body of message...
                    mail.Body = "Body text goes here...";

                    // HTML: Create a table with background image and some text and additional image...
                    string bodyHtml = "<html><body>"
                        // create a table border...
                        + "<table border='3' width='720' height='480' ALIGN='center' ><tr><td>"
                        // place a table inside table border with a background image...
                        // NOTE: image will repeat if smaller that table dimensions...
                        + "<table background='cid:imageId' border='0' width='715' height='475' "
                        + "ALIGN='center' ><tr><th colspan='3' height='40'></th></tr>"
                        + "<tr ><td width='200'></td>"
                        // add some font/text stuff...
                        + "<td width='350' align='center'><font color='#800000' face='Mistral' size='8' >"
                        + "<b>Have a Very Merry Christmas</b><br/>"
                        // add additional font/text stuff...
                        + "</font><b><font color='#800000' face='Comic Sans MS' size='5'>"
                        + "Best Wishes from DdoubleD</font></b></td>"
                        // overlay particular area with another image (I just used same image):
                        + "<td width='170'><img src='cid:imageId' …
sknake commented: very nice! +6
DdoubleD 315 Posting Shark

You have non-readable/printable characters in your input file. In c#, a "char" (Unicode representation) is 2 bytes, or 2^16, which has a max value of 65536. I'm not sure what it is you expect. You could force the output to be max byte length:

sw.WriteLine(Convert.ToInt16(((byte)b[i])));

but, I don't know how that helps you or what you are trying to do...

Have a look at these articles:
Unicode...
Extended ASKII...

DdoubleD 315 Posting Shark

The code I gave you uses ListBox's, but the principles are the same for ListView as far as modifying the collection of items. When you say "Refresh", I don't know what you mean exactly because it does you no good to perform a ListView.Refresh() if the form is hidden; and, it will occur automatically when the form is shown again.

Did you try the code? And, if there is something I am not understanding in your question, could you post the code or attach your project so I can see what you are trying to do?

I just added listBox1.Refresh() to the add items loop, and it doesn't care whether the form is visible or not... It doesn't error.

DdoubleD 315 Posting Shark

This code will limit allowed character input to a-z and A-Z characters:

const string regExpr = "[a-z]";
        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(e.KeyChar.ToString().ToLower(), regExpr);
            if (!m.Success)
                e.Handled = true;
        }

You need to add the event handler in your form's constructor after the InitializeControls() call:

this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);

or, you can use the designer to add the event handler to the KeyPress event.

DdoubleD 315 Posting Shark

It doesn't matter whether the form is visible or not. I put this form demonstration together for you to see how the forms can manipulate the other forms' lists. Add them to a form project and call Application.Run(new Form_modal())

DdoubleD 315 Posting Shark

thanks, worked.

but what's the difference between "?" and "@" ?

My understanding is that the "?" represents a place holder that is not named, which means you can represent values like: VALUES (?, ?, ?, ?)... Sql Server does not support "?" placeholders, but uses named parameters: VALUES (@fld1, @fld2, @fld3, @fld4, @fld5)...

When using placeholders, I believe the names are ignored, eg: VALUES (?fld1, ?fld2, etc.) would ignore the text following the "?".

With "?" place holders, you must have them in the correct order or the command will fail or unexpected results could occur. With "@" named parameters, the parameter values will be matched to the fields by name.

I suspect the defined "parameter marker" ("?", or "@") is solely determined by the specific data provider, so you might find a library that allows you to use named parameters ("@") with MySql command parameterization--I just don't know if this is true.

sknake commented: Excellent!!! That is _exactly_ what I would have said :P +6
DdoubleD 315 Posting Shark

Once you remove all the references to your button objects stored in your array, the garbage collector will take care of the cleanup. You can then reallocate (reuse) your array for further usage.

// step 1 allocate...
            ButtonArray = new Button[10, 100];

            // step 2 remove reference to button objects; garbage collector will handle cleanup...
            ButtonArray = null;

            // step 3 allocate...
            ButtonArray = new Button[2, 5];

In the above, you could skip step 2 and perform step 3 because it will have the same affect of removing the references to the original button objects...

If any other existing objects reference any of the buttons, they will exist until all references have been remove--this is expected and desired.

ddanbe commented: Helpfull explanation! +5
DdoubleD 315 Posting Shark

Dates need to be enclosed with hash (#) symbol. Try:

string str = "Select * from Customer where SubmitDate between #" + str1 + " 12:00:00 AM#" + " and #" + str2 + " 12:00:00 PM#";
DdoubleD 315 Posting Shark

Might be your using named parameters... Are you getting NULL values in the table? Try changing "@" to "?" and see what you get.

DdoubleD 315 Posting Shark

Please have a look at this: http://dotnetperls.com/dllimport-interop

DdoubleD 315 Posting Shark

If the record containing the values exists, then you only need:

if (dr.Read())
            {
                MessageBox.Show("Log-in Successful.");
                formMain main = new formMain();
                this.Hide();
                main.Show();
            }
            else
                MessageBox.Show("Log-in Failed.");

because if anything exists in the reader then a match was already found.

What I mean to say is that you are already performing a check against the DB for a matching record, so there is no need to also perform your CompareStrings . You can just check the reader dr.Read() contents to see if it found a match...

DdoubleD 315 Posting Shark

EDIT: NEVERMIND THIS BECAUSE I DIDN'T SEE YOU HAD THE DEFINITION POSTED: Are you sure the CompareStrings method is always return true? From what library is your CompareStrings ? Look at the definition to determine it why it is always returning true.

Why are you selecting the 'matching' record for username and password from your DB, then again checking to see if you have a match?

You are building your SqlDataReader object ( SqlDataReader dr = cmd.ExecuteReader() ), but not reading from it. See this example: http://msdn.microsoft.com/en-us/library/aa326245(VS.71).aspx

DdoubleD 315 Posting Shark

Thank you for your suggestion.Actually I need to check memory cards by copying a file to it and reading that from memory card.Can I know whether any DLLs available for this "File and Stream I/O classes" so that I can easily use it in other programming languages also.
I used the dll shell32 for formating the drive.

As long as .NET framework is installed on the machine in question, you don't need to worry about the dll's; just check the minimum .NET version information for the functionality you wish to use: http://msdn.microsoft.com/en-us/library/k3352a4t.aspx

DdoubleD 315 Posting Shark

I looked at the file and it appears to be formatted, but I'm not sure what the format is. However, the question remains as to what you are trying to do as you are currently just reading in each character one at a time and storing it in your int[] , upto 5000 chars, then outputting the decimal equivalent of each of those chars. Is this intended?

DdoubleD 315 Posting Shark

You have your "sr" and "sw" naming conventions reversed :D, but that is not your problem...

Your call to b[i] = sw.Read(); will only read a character at a time, which is why you cannot get the values you expect, presumably.

Look at the Read method spec and see if this helps. Otherwise, attach your input file so we can see how it is constructed.

EDIT: I think I misunderstood what you are doing. It is your intention to read each character and convert it to it's "decimal" equivalent? Just cast the return from Read to an unsigned int.

DdoubleD 315 Posting Shark

It's probably due to a difference between the version of VS you have and the version of VS discussed in the tutorial you are using. Try stepping through your wizard and see if you can identify the options you are concerned with that your tutorial or book discusses. If still cannot get the desired report format, update the thread with details of what you want to achieve or you can search for a tutorial that is specific to your version of VS.

DdoubleD 315 Posting Shark
// Set the number of rows to step through...
                progressBar1.Maximum = ds.Tables[0].Rows.Count;

                // Set the increment size...
                progressBar1.Step = 1;

then to maintain progress:

cmd1.ExecuteNonQuery();

                        // Increment progress...
                        progressBar1.PerformStep();

You should also move the sqlConn.Open(); outside of your loop, which is why I didn't include it above. There is no need to reopen the connection for every command (INSERT) you are executing.

DdoubleD 315 Posting Shark

Nope, it didn't work as well... (T-T)

What is the error you are getting?

DdoubleD 315 Posting Shark

Twice I have received "token expired" error trying to reply to this... I am really peeved! Anyway, run the program outside the debugger and check the debug\application.exe.config file for the changes. I would explain further, but I've already wasted a 1/2 hour trying too...

EDIT: I'll try to elaborate briefly and hope I don't get another "token expired"...

When you build your app, it will create the application.exe.config file. When you run in the debugger, it will update the application.vshost.exe.config file. When you make changes in the debug mode, it will update the vshost file, but not the other. However, when you run outside the debugger it will update the application.exe.config file...

tig2810 commented: you da man +1
DdoubleD 315 Posting Shark

what is the memorystream ?

It is a class that allocates a storage area (unsigned byte array) in memory (RAM) that can be acted upon by I/O classes expecting a Stream during construction/initialization. Because bitmaps/images are generally associated with files, classes that manipulate/operate on them contain methods that expect a Stream (such as FileStream), so to access those methods we converted the byte array to a MemoryStream. Refer to MemoryStream class and System.IO Namespace for further information regarding streams.

Geekitygeek commented: Clear and concise reply. Great work as always :) +1
DdoubleD 315 Posting Shark

Ensure you have all the appropriate NotifyFilter and Filter settings. Here is an excerpt from the MSDN example:

/* Watch for changes in LastAccess and LastWrite times, and
           the renaming of files or directories. */
        watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
           | NotifyFilters.FileName | NotifyFilters.DirectoryName;
        // watch all files
        watcher.Filter = "*.*";

You might also try adding NotifyFilters.CreationTime to the above flag attributes, but it would seem unnecessary due to the LastWrite attribute.

DdoubleD 315 Posting Shark

Because each element of "m" will reference the same "record" object, which will contain whatever the last items added to the record are. You need to move the creation of the "record" into the loop so that each "record" of "m" is a different object:

for (int i = 0; i < 5; i++)
            {
                string[] record = new string[3];
                record[0] = "1";
                record[1] = fr[i];
                record[2] = bd[i];
                m.Add(record);
            }

EDIT: Tower-Rounder already replied before i got to it...

DdoubleD 315 Posting Shark

Since the SetAttribute method sets the value of the name, you wouldn't want the value for "checked" to be "unchecked" because it expects a state flag value for a checkbox's state. Have you tried: SetAttribute("checked", "false") ?