Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Working with multiple forms

Working with multiple forms

Scheduled Pinned Locked Moved C#
helpquestion
20 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B bwood2020

    Sorry, I'm not following. As you can guess I am not a very good programmer. Just starting out and I thank you for your patience. I do not have any private fields in the second form. Do I need to declare gd as private? Something like: public void textBox1_TextChanged(object sender, EventArgs e) { GD = textBox1.Text; gd = GD; } private string gd; public string GD { get { return gd; } set { gd = value; } }

    H Offline
    H Offline
    Henry Minute
    wrote on last edited by
    #11

    Almost right. Well worked out! just a small change

    public void textBox1_TextChanged(object sender, EventArgs e)
    {

    GD = textBox1.Text;
    gd = GD; // this line is not needed. When you say GD = textBox1.Text, the lines in the set part of GD
    // (called the setter, guess what the get part is called) get executed; gd = value.
    // The value is whatever is on the right of the = in GD = textBox1.Text

    }
    private string gd;
    public string GD
    {
    get { return gd; }
    set { gd = value; }
    }

    Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

    B 1 Reply Last reply
    0
    • H Henry Minute

      Almost right. Well worked out! just a small change

      public void textBox1_TextChanged(object sender, EventArgs e)
      {

      GD = textBox1.Text;
      gd = GD; // this line is not needed. When you say GD = textBox1.Text, the lines in the set part of GD
      // (called the setter, guess what the get part is called) get executed; gd = value.
      // The value is whatever is on the right of the = in GD = textBox1.Text

      }
      private string gd;
      public string GD
      {
      get { return gd; }
      set { gd = value; }
      }

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      B Offline
      B Offline
      bwood2020
      wrote on last edited by
      #12

      All right, it works!!! One more issue though. I placed a messageBox in the code on the first form and I am getting the correct string delimiter. So I know GD is storing this, however, when I go to call GetDelimiter.GD for the in the connection I get an ArgumentException was unhandled error: Format of the initialization string does not conform to specification starting at index 85. Here is the connection string: String comString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(FilePath) + @";Extended Properties=""text;HDR=YES;FMT=Delimited["+ GetDelimiterForm.GD +"]"; The error occures at: OleDbConnection conTXT = new OleDbConnection(comString); I know it has something to do with FMT=Delimited["+ GetDelimiterForm.GD +"]"; because if I hard code it it has no problems (FMT=Delimiter(TAB)""";). I have tried replacing "[" with "(" and that doesn't work. Any ideas on this one?

      H 1 Reply Last reply
      0
      • B bwood2020

        All right, it works!!! One more issue though. I placed a messageBox in the code on the first form and I am getting the correct string delimiter. So I know GD is storing this, however, when I go to call GetDelimiter.GD for the in the connection I get an ArgumentException was unhandled error: Format of the initialization string does not conform to specification starting at index 85. Here is the connection string: String comString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(FilePath) + @";Extended Properties=""text;HDR=YES;FMT=Delimited["+ GetDelimiterForm.GD +"]"; The error occures at: OleDbConnection conTXT = new OleDbConnection(comString); I know it has something to do with FMT=Delimited["+ GetDelimiterForm.GD +"]"; because if I hard code it it has no problems (FMT=Delimiter(TAB)""";). I have tried replacing "[" with "(" and that doesn't work. Any ideas on this one?

        H Offline
        H Offline
        Henry Minute
        wrote on last edited by
        #13

        When you hard code it you are using slightly different syntax Hard coded: FMT=Delimiter(TAB) Using GetDelimiterForm: FMT=Delimited[...... Delimiter and Delimited, or is that just a typo?

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        B 1 Reply Last reply
        0
        • H Henry Minute

          When you hard code it you are using slightly different syntax Hard coded: FMT=Delimiter(TAB) Using GetDelimiterForm: FMT=Delimited[...... Delimiter and Delimited, or is that just a typo?

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          B Offline
          B Offline
          bwood2020
          wrote on last edited by
          #14

          I apologize, it was a typo. What I meant was Hard Coded: FMT=Delimited(TAB) \\This works Using GetDelimiterForm: FMT=Delimited["+ GetDelimiterForm.GD +"]\\This throws the error

          H 1 Reply Last reply
          0
          • B bwood2020

            I apologize, it was a typo. What I meant was Hard Coded: FMT=Delimited(TAB) \\This works Using GetDelimiterForm: FMT=Delimited["+ GetDelimiterForm.GD +"]\\This throws the error

            H Offline
            H Offline
            Henry Minute
            wrote on last edited by
            #15

            It is the double quote thing for Extended Properties that is causing the problem. In order to get a quotation mark within a literal string you have to 'escape them' This means that the double quotes in the middle have to look like \"\", for them to be recognised as quotes within a string. When this is all over look up Escape Characters for a better explanation. In the mean time take a look at ADO Connection Strings[^], for some examples. Search in the article for 'Extended Properties' and you'll see what I mean. Have a play. Good Luck! :)

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

            B 2 Replies Last reply
            0
            • H Henry Minute

              It is the double quote thing for Extended Properties that is causing the problem. In order to get a quotation mark within a literal string you have to 'escape them' This means that the double quotes in the middle have to look like \"\", for them to be recognised as quotes within a string. When this is all over look up Escape Characters for a better explanation. In the mean time take a look at ADO Connection Strings[^], for some examples. Search in the article for 'Extended Properties' and you'll see what I mean. Have a play. Good Luck! :)

              Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

              B Offline
              B Offline
              bwood2020
              wrote on last edited by
              #16

              Thank you Henry for all your help. I will look into this today.

              1 Reply Last reply
              0
              • H Henry Minute

                It is the double quote thing for Extended Properties that is causing the problem. In order to get a quotation mark within a literal string you have to 'escape them' This means that the double quotes in the middle have to look like \"\", for them to be recognised as quotes within a string. When this is all over look up Escape Characters for a better explanation. In the mean time take a look at ADO Connection Strings[^], for some examples. Search in the article for 'Extended Properties' and you'll see what I mean. Have a play. Good Luck! :)

                Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                B Offline
                B Offline
                bwood2020
                wrote on last edited by
                #17

                Hi Henry, I have read a couple articles on escape sequences and have tried to include the same line of code(just modified to fit what I need) and I still get errors. Maybe I am looking in the wrong place but when I try and use Extended Properties=\"\"text;HDR=Yes;FMT=Delimited(" + gds + ");\"\";"; it says I need to add ";". But when I add one it tells me I need to add another. However, if I were to plug the line of code above into the code found in the Code Project page it seems fine. I think what is happening is that there is something wrong with the first part of the connection string, maybe the Source. "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(FilePath) + @"; Could you look at this one more time for me and point me in the right direction when you have time please? Here is the entire connection string: String comString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(FilePath) + @";Extended Properties=\"\"text;HDR=Yes;FMT=Delimited(" + gds + ");\"\";"; Thank you, Brenton

                H 1 Reply Last reply
                0
                • B bwood2020

                  Hi Henry, I have read a couple articles on escape sequences and have tried to include the same line of code(just modified to fit what I need) and I still get errors. Maybe I am looking in the wrong place but when I try and use Extended Properties=\"\"text;HDR=Yes;FMT=Delimited(" + gds + ");\"\";"; it says I need to add ";". But when I add one it tells me I need to add another. However, if I were to plug the line of code above into the code found in the Code Project page it seems fine. I think what is happening is that there is something wrong with the first part of the connection string, maybe the Source. "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(FilePath) + @"; Could you look at this one more time for me and point me in the right direction when you have time please? Here is the entire connection string: String comString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(FilePath) + @";Extended Properties=\"\"text;HDR=Yes;FMT=Delimited(" + gds + ");\"\";"; Thank you, Brenton

                  H Offline
                  H Offline
                  Henry Minute
                  wrote on last edited by
                  #18

                  I have found an article that is doing what I think you are trying to do. Read text file (txt, csv, log, tab, fixed length)[^], it only uses one \" instead of two. Have a look and see if it helps.

                  Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                  B 1 Reply Last reply
                  0
                  • H Henry Minute

                    I have found an article that is doing what I think you are trying to do. Read text file (txt, csv, log, tab, fixed length)[^], it only uses one \" instead of two. Have a look and see if it helps.

                    Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                    B Offline
                    B Offline
                    bwood2020
                    wrote on last edited by
                    #19

                    That did it Henry. Thank you so much. Is there something I need to do is far as closing this out or giving you a rating? Let me know and I will come back.

                    H 1 Reply Last reply
                    0
                    • B bwood2020

                      That did it Henry. Thank you so much. Is there something I need to do is far as closing this out or giving you a rating? Let me know and I will come back.

                      H Offline
                      H Offline
                      Henry Minute
                      wrote on last edited by
                      #20

                      Thanks for the thanks! If you would just vote one of my posts as a 5, then people will know that your question has been answered. Good luck! :)

                      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups