Click here to Skip to main content
16,019,087 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to everybody,

first here is my code 

<pre>  private void GetButtonsTextFile(object sender, EventArgs e)
        {

controlName = ((Control)(sender)).Name;  //Type c# -> string | Type-> Database char
parentName = ((Control)(sender)).Parent.Name; //Type in c# -> string | Type-> Database char
controlLocation = ((Control)(sender)).Location;//Type in c# ->  System.Drawing.Point | Type in Database -> point
parentLocation = ((Control)(sender)).Parent.Location; //Type in c# System.Drawing.Point | Type in Database -> point

            datastring = controlName + ";" + parentName + ";" + DateTime.Now.ToString() + ";" + memberID + ";" + controlLocation + ";" + parentLocation;
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(filepath, true))
            {
                try
                {
                    file.WriteLine(datastring);
                }
                    catch (System.IO.IOException ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }


Im writing some parameter of the object which calls the Methode GetButtonsTextFile() to a TextFile. This works fine.

Now i want to transfer the content of the textfile to the colums of the table of my mysql database. All types are string. Only the columns for buttonLocation and parentLocation are from the type point (See comments).

I transfer the content of the textfile with this mehtode:

public void SendFileToDatabase()
      {
          try
          {
              OdbcConnection dbConnection = new OdbcConnection(connectionstring);
              dbConnection.Open();
              loadTxtToTable = "LOAD DATA LOCAL INFILE '" + filepath + "' INTO TABLE " + table + " FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n'";
              OdbcCommand LoadFileToTable = new OdbcCommand(loadTxtToTable, dbConnenction);
              LoadFileToTable.ExecuteNonQuery();
              dbConnection.Close();

          }
          catch (System.Data.Odbc.OdbcException ex)
          {
              MessageBox.Show(ex.ToString());
          }
      }


Without the point paramters the tranfer works fine, but if i try to transfer the point paramters to the desired fields it doesnt work.

The exeption says: cannot get geometry object from data you send to the Geometry Field

I could make them as string but i need them as point objects because later i want to display them as points in a chart. Or is there a way to display string points from a field to a chart?

Does somebody has a suggestion?

Appreciate.. Thanks a lot


What I have tried:

looking for similar artices, msdn, google
Posted
Updated 6-Jan-17 8:16am

1 solution

You have to store the points in the database as integers (or floats, depending on which UI framework you're using). You're going to need fields for X, Y, Width, and Height, as well as a way to identify a given button.
 
Share this answer
 
v2
Comments
Member 12341536 6-Jan-17 16:49pm    
Hi John, thank you for answering.

Well this is obviously an easy way to do it.I Will do it this way i think. But do you have an idea in which format the type "point" in the database should look like. I mean does it expect only 2 numbers with a space between. like "x y" or brakets and no space between x and y like "{xy}" oder a comma between like x,y.. than i could modify the string to fit the expected format. Maybe it would regognize the string as a Point.

Thanks in advance.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900