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

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

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

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

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

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

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

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

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
// 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

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

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

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 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

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

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
DateTime datetime = DateTime.ParseExact("10/10/2009 12:00:00", "MM/dd/yyyy hh:mm:ss", System.Globalization.CultureInfo.CurrentCulture);

Also, have a look at this: http://msdn.microsoft.com/en-us/library/system.datetimeoffset.tryparseexact.aspx

DdoubleD 315 Posting Shark

Take a look at this MS link and look at the example code where instead of filtering numeric digits, they filter everything else... Just modify that code to only accept the characters you want. Cheers!

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keypress.aspx

Geekitygeek commented: always there first with great info :p +1
DdoubleD 315 Posting Shark

I followed your suggestion using MDIParent VS default and changed my idea of use a lot child form in sequence. I will perhaps use panels or tabs, then hide or visible to false.

Only a little question, using MDIParent VS default which is the best way to create the form options (like menustip>Options>Configuration, then display a form) to interact to the childform? Create a winform without being child, then use "get and set"?

Thanks!

>>using MDIParent VS default which is the best way to create the form options (like menustip>Options>Configuration, then display a form) to interact to the childform?

The menu that it generates contains items that represent common menu features found in MDI applications. You can add/remove them to suit your own needs.

>>Create a winform without being child, then use "get and set"?

You may not want to use a MDI approach to what it is you are doing. Because of the way you were trying to implement the Form.MdiParent , I thought I should direct you to the "shell" Windows Form item type that you could add to your project that gives an idea of how to interact with a MDI Parent.

Here is a link to MSDN MDI programming...

It is not clear to me what the purpose of your application is, so I don't want to recommend one way over another. However, using the MdiParent property as you were attempting to do for each form without maintaining a …

DdoubleD 315 Posting Shark

Thanks
I am reading a book named crystal reports for dummies. Just started!

I have to handle only a small data set. only 72 records. No different reports - only one report. I have no database, only a text file with these 72 records.
Will this huge report writer(crystal reports) be a overkill?
still may be useful in future projects, right?

Thanks

I think Crystal Reports is the most popular/versatile for the $price$ too. As far as the overhead it produces, that would be easy enough for you to determine. Just build one project with and one without...

There is a control in Visual studio called Microsoft Report Viewer. I think that is a simple report generator compared to crystal reports. Let me see weather I can use it for my purpose.
Also in Projects->Add New Items->Reporting-> report and report wizard. Just cant figure out what are the difference between these reporting tools.

Thanks
Roy Thomas

I haven't done anything with the built in Report Viewer and don't know much about it, but I will know more if you post your findings here. ;)

RoyMicro commented: Helpful +1
DdoubleD 315 Posting Shark

Overview:

Oddly enough, MS never created a TreeViewDrowDown or equivalent. What I mean, is a control that looks and acts like a ComboBox , but contains a TreeView instead of just a list when in the expanded drop-down mode. I've never understood why they haven't, but I always seem to want to incorporate such a control into a design/form. So, a few months ago while working on an application, I decided to create such a control (or rather fake it on a form) in C#.

In this particular example, I have a pseudo drop-down TreeView control that is intended to drive the contents of the TabControl on the form. However, I did not take the time to demonstrate this activity by populating the TabPages with other controls.:( Let it suffice to say, the "Drop Down TreeView" would drive the rest of the form (TabControl) in this example. In addition, the design and implementation herein is not really a custom control, or a UserControl for that matter, but rather a way to fake the appearance of a TreeViewDropDown control on a Windows Form. Here is a sample (runtime) of the form when the TreeView control is hidden:

[IMG]http://www.daniweb.com/forums/attachment.php?attachmentid=12681&stc=1&d=1258944292[/IMG]

And, here is what the control looks like when it is Visible (also at runtime):

[IMG]http://www.daniweb.com/forums/attachment.php?attachmentid=12680&stc=1&d=1258944292[/IMG]

The actual controls used to create this effect consist of a TextBox, Button (with down-arrow image), and a TreeView that get's made visible when active and then …

ddanbe commented: Nice snippet! +5
DdoubleD 315 Posting Shark

This is a pretty good article as far as comparing Windows Forms to WPF at a high level: DECIDING WHEN TO ADOPT WINDOWS PRESENTATION FOUNDATION

To find examples of some technologies you are interested in, try looking on CodeProject.com and CodePlex.com.

Geekitygeek commented: really informative article :) +1
ddanbe commented: Yes, nice article! +5
DdoubleD 315 Posting Shark

Hi,

No excuses: my problem is that I can't get my code to check if a certain record exists in a MSA database.

My code needs to check if the database contains a row where 2, 3 or 4 specified fields exist.
But, as mentioned, at the moment it only gives errors about missing parameters.
Before I post the code I'd like to know what the correct way is, as the code is very secret :).

Very secret...OK :cool: Here is an example of getting a count of records meeting a specific ID in a where clause:

using (OleDbConnection conn = new OleDbConnection(connStr))
                {
                    try
                    {
                        conn.Open();
                    }
                    catch (Exception Ex)
                    {
                        MessageBox.Show(Ex.Message);
                        System.Diagnostics.Debugger.Break();
                    }

                    string cmdStr = "Select count(*) from customers where id = 4";
                    OleDbCommand cmd = new OleDbCommand(cmdStr, conn);
                    int count = (int)cmd.ExecuteScalar();
                }
DdoubleD 315 Posting Shark

I suppose the main thing you are giving up is streamlined maintenance and scalability since you will need to manually copy and paste (or perhaps remove) segments of code anytime the size of the container gets changed.

Why are you avoiding loops?

DdoubleD 315 Posting Shark

To obtain the size of your list: properties.Count . To access a member of Property named pos in a loop:

for (int i=0; i<properties.Count; i++)
{
    if (player1pos == properties[i].pos) 
    {
          // but, this will error (using i+1) if "i" is already at Count-1:
         player1pos = properties[i+1].pos;
         x = x - 1;               
    }
  }
DdoubleD 315 Posting Shark

If I want to create the file (text file) in the current folder where my exe is running, how should I pass the file name argument in filestream instantiation?
Thanks
Roy Thomas

Hi Roy. If you pass in just the filename (no path), the file will be created in the same folder as where your application is running, which is the current working directory. The only caveat to this is, if your application's process changes the current working directory.

ddanbe commented: Clear explanation. +5
DdoubleD 315 Posting Shark

If you intend to parse or convert the byte[] into its string equivalents, the StreamWriter should work fine as long as long as it does not need to be thread safe. For thread safety, look at TextWriter .

If you just want to write the byte[] to a file, look at FileStream class.

If you intend to parse the byte[] array into various types, consider using the BinaryWriter class.

Geekitygeek commented: clear and concise :) +1
DdoubleD 315 Posting Shark

The first thing you need is a database--do you have one? Then, you need to build a proper connection string to connect to it with: http://www.connectionstrings.com/. How you proceed from here depends on the database type, but the basic, most common stuff, involves:

1) Opening a connection
2) Building a SQL command
3) Executing the command

There are infinite examples on the web, but if you cannot find some really "basic" examples for your database type, let us know what DB you are using and I'm sure we can point you to a few.

Cheers!

ddanbe commented: informative +5
DdoubleD 315 Posting Shark

I searched my registry and found the following key, which returned 1.6.0_15 on my machine:

RegistryKey rk = Registry.LocalMachine;
            RegistryKey subKey = rk.OpenSubKey("SOFTWARE\\JavaSoft\\Java Update\\Policy");
            string currentVerion = subKey.GetValue("InstalledJREVersion").ToString();

EDIT: If using the above, just concatenate the currentVersion to the "Jdk version: " text: Text = "Jdk version: " + currentVersion;

DdoubleD 315 Posting Shark

First of all, I have noticed that you later reposted this problem you are having, which is not proper to do. I provided you with a reply in that repost about what I saw as a problem.

Secondly, see my comments regarding your posts below:

actually storing the byte array to access database is not a problem
its gets stored the only thing is when i try to retrieve the same byte array from access database i am getting only 25bytes

WHY IS THAT SO

In the above, you have made a FALSE assumption that you are correctly inserting your byte array, which is proven by the code snippet you provided following! Had you tried to understand what adatapost was showing you in the snippet he provided to you, your problem might already be solved!

FileStream fs = new FileStream("encrypted.txt", FileMode.Open);

            byte[] buff = null;
            BinaryReader br = new BinaryReader(fs);
            long numBytes = new FileInfo("encrypted.txt").Length;
            buff = br.ReadBytes((int)numBytes);

           mycon.Open();
           OleDbCommand cmd = new OleDbCommand("INSERT INTO song VALUES('1','" + buff + "')", mycon);
            cmd.ExecuteNonQuery();
            mycon.Close();
            fs.Close();
// above code is inserting part 

//below code is extracting part 
           byte[] temp = new byte[200000000];
           mycon.Open();

           OleDbCommand cmd = new OleDbCommand("select file from song", mycon);
           System.Data.OleDb.OleDbDataReader dr;
           dr = cmd.ExecuteReader();
           dr.Read();
           temp = (byte[])dr["file"]; //only 25 bytes i am getting
           int len = temp.Length; //25 length 

           FileStream fs = new FileStream(@"C:\Documents and Settings\SHREESHILA1\Desktop\dummy.txt", FileMode.Create);
           fs.Close();

           BinaryWriter br = new BinaryWriter(File.Open(@"C:\Documents and Settings\SHREESHILA1\Desktop\dummy.txt", FileMode.Open));


           br.Write(temp);

           //br.Write(temp);
           br.Close();  

now check the …

kvprajapati commented: Well said! +6
DdoubleD 315 Posting Shark

thanks everyone.
string s = string.Format("{0}\r\n{1}\r\n{2}\r\n", ary.ToArray());
MessageBox.Show("My ArrayList contains:\r\n\r\n" + s);

these lines seem intresting but how would you do it for an index - which can constantly get bigger by the users input? . for example 3 values one time , 4 values another time or X values another time.

it has to be in an array or arraylist which is kinda of a shame as list<> is easier no dought.
-----------------------------------------------------------------

You could use a loop to build the string. In the following example, notice that the loop resolves each item to an object type before casting it to a string . This is because ArrayList is not a "strongly typed" container and treats its items simply as object types. Unfortunately, this also means you could store mixed types in the array, which would cause an error if you try to cast it to the wrong type.

string s2 = string.Empty;
                foreach (object oString in ary)
                    s2 += (string)oString + "\r\n";
                MessageBox.Show("My ArrayList contains:\r\n\r\n" + s);
brightsolar commented: Wow, Practically a Posting Shark = True lol. +1
DdoubleD 315 Posting Shark

As you have already learned by now, naming conventions are completely voluntary unless you are constrained to adhering to a standard. IMO, and until you find yourself confined to such constraints, continue learning and adopting naming techniques as you go along.

I would like to point out that consistency can be more important than adhering to any one particular set of naming rules because if you have ever tried to walk through code that has been touched by several different programmers where each programmer had their own way of defining/expressing code meaning/behavior, it can be more difficult to follow and understand. When working with large projects/solutions/workspaces (whatever), it is best to add and/or modify existing code files and libraries by keeping consistent with conventions already in place.

ddanbe commented: Well said! +5
DdoubleD 315 Posting Shark

Here is an example for your messagebox question in which the ArrayList is cast to an Array, which the string.Format method can then use to format a string with individual placeholders (eg. {0}, {1}, etc.):

ArrayList ary = new ArrayList();
                ary.Add("one");
                ary.Add("two");
                ary.Add("three");
                string s = string.Format("{0}\r\n{1}\r\n{2}\r\n", ary.ToArray());
                MessageBox.Show("My ArrayList contains:\r\n\r\n" + s);

In order to sort the array: ArrayList.Sort . If you need to sort complex items, you need to provide an IComparer .

You may wish to consider using List<> (eg. List<int>) instead of an ArrayList in the future.

DdoubleD 315 Posting Shark

No problem. The foreach loop is iterating through the form's control list, which is maintained by the designer every time you add or remove controls to/from your form. Then, we are checking the name of the control (c.Name) to find the labels: label1 - label3, based on what you said you would like. If the label control's name matches the current control, then we are setting it's Visible property (c.Visible) to true.

Geekitygeek commented: a good answer and a clear explaination :) +1
DdoubleD 315 Posting Shark

This will loop through all of the form's controls searching for the name of the control....

private void button2_Click(object sender, EventArgs e)
        {
            for (int i = 1; i <= 3; i++)
                foreach (Control c in this.Controls)
                    if (c.Name == "label" + i)
                        c.Visible = true;
        }
DdoubleD 315 Posting Shark

If I have understood correctly, you are wanting to perform a paragraph split when it exceeds the page length? I don't have a direct answer for you and these pdf libraries/utilities generally have a learning curve associated with their lack of documentation, etc. However, you might want to consider alternatives to PdfSharp, depending on what you are doing. If you haven't checked out iTextSharp yet, you might want too. With the following code snippet, I produced an 8 page pdf (horizontal layout) as a result of a long paragraph. There are also header and footer options.

Code snippet:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using PdfSharp.Pdf;
//using PdfSharp.Drawing;
//using PdfSharp.Drawing.Layout;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;

namespace ForumSolutions
{
    public class AcrobatReaderStuff
    {
        public static void Test_iTextSharp()
        {
            Document myDocument;

            myDocument = new Document(PageSize.A4.Rotate());

            PdfWriter.GetInstance(myDocument, new FileStream("c:\\Test_iTextSharp.pdf", FileMode.Create));

            myDocument.Open();

            string tmp = "";
            for (int i = 0; i < 1000; i++)
                tmp += " Here is some more text (" + i + ")... ";

            myDocument.Add(new Paragraph(tmp));

            myDocument.Close();
        }
    }
}

And, here is the Document class definition:

public class Document : IDocListener, IElementListener
    {
        protected int chapternumber;
        protected bool close;
        public static bool Compress;
        protected HeaderFooter footer;
        protected HeaderFooter header;
        protected string htmlStyleClass;
        protected string javaScript_onLoad;
        protected string javaScript_onUnLoad;
        protected float marginBottom;
        protected float marginLeft;
        protected bool marginMirroring;
        protected bool marginMirroringTopBottom;
        protected float marginRight;
        protected float marginTop;
        protected bool open;
        protected int pageN;
        protected Rectangle pageSize;
        public static float WmfFontCorrection;

        public Document();
        public …
TobbeK commented: Very kind, clear and helpful in his comments +2
DdoubleD 315 Posting Shark

If not required to use Array or ArrayList, I wouldn't use either. Use a typed list instead: List<> .

I would put the method outside of your Team class, but it really depends on where you intend to store your Team list or array.

The best way to return an array or list of objects depends on how you intend to use the returned object.

DdoubleD 315 Posting Shark

Ok, I figured out that the error was actually triggered further down the code. It seems none of my parameters are being added into the query. I'm going to post the rest in case anyone can see what is wrong with it...

OdbcCommand myCommand = myConnection.getCommand("INSERT INTO entries(text, name, screen_name, user_id, posi_score)values(@txt, @nm, @scrNm, @uid, @posi_score)");
                myCommand.Parameters.AddWithValue("@txt", txt);
                myCommand.Parameters.AddWithValue("@nm", nm);
                myCommand.Parameters.AddWithValue("@scrNm", scrNm);
                myCommand.Parameters.AddWithValue("@uid", uid);
                myCommand.Parameters.AddWithValue("@posi_score", posiScore);
                myConnection.openConnection();
                try
                {
                    myConnection.executeNonQuery(myCommand);
                }
                catch (Exception e)
                {
                    Console.Write("Insert failed on entries "+e.Message);
                }

Is there another way to pass these parameters in for an Odbc connection? I worked fine with a straight SQL server connection...

As I understand it, ODBC parameters are positional, not named. So, you would need to have something like this, making sure your parameters are added in the same order as they appear in your SQL statement:

OdbcCommand myCommand = 
                    new OdbcCommand("INSERT INTO entries(text, name, screen_name, user_id, posi_score)values(?,?,?,?,?)");
                myCommand.Parameters.AddWithValue("txt", txt);
                myCommand.Parameters.AddWithValue("nm", nm);
                myCommand.Parameters.AddWithValue("scrNm", scrNm);
                myCommand.Parameters.AddWithValue("uid", uid);
                myCommand.Parameters.AddWithValue("posi_score", posiScore);

EDIT: You may want to consider using a different library to connect to MySQL. I am using MySql.Data.dll, which you can find that and others available free on the internet.

DdoubleD 315 Posting Shark

You can also add the event handler directly in your form's constructor in the form of:

public Form1()
        {
            InitializeComponent();
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
         }
DdoubleD 315 Posting Shark

You can handle the close event on the form using the following event handler:

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult.No == MessageBox.Show("Exit without saving changes?", "Data Not Saved", MessageBoxButtons.YesNo))
                e.Cancel = true;
        }

The above event will be called whenever the Close() method is executed. Use e.Cancel = true to stop the form from being closed.

DdoubleD 315 Posting Shark

Have never tried doing that, but here are some interesting links I found while reading up on the subject:

Notification Services...

Send SMS from a Trigger...

xp_cmdshell...

DdoubleD 315 Posting Shark

Hi glado24! Got here as fast as I could...

Now, did you need the complete application with documention and help files attached or just the MySQL database-wrapper interface library?--just kidding--:D

If you search the forum, you should find many examples of what you are asking for, and even some threads related specifically to MySQL. Put together some code using these and other examples from the web and then post more specific question/need based on any problem your having.

There is great DB coding help in this forum when you post a more specific question. ;)

Cheers!

Antenka commented: lol :D +1