从texrtfile到SQL数据库的转移点(点数字段) [英] Transfer points from texrtfile to SQL database (point field)

查看:121
本文介绍了从texrtfile到SQL数据库的转移点(点数字段)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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());
                }
            }
        }





我正在写一个调用Methode GetButtonsTextFile的对象参数()到TextFile。这很好。



现在我想将文本文件的内容传输到我的mysql数据库表的列中。所有类型都是字符串。只有buttonLocation和parentLocation的列来自类型点(参见注释)。



我用这个mehtode传输文本文件的内容:





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());
          }
      }





如果没有积分参数,转移工作正常,但如果我尝试将点参数转移到它不起作用的所需字段。



例外说:无法从发送到几何字段的数据中获取几何对象



我可以将它们作为字符串,但我需要它们作为点对象,因为后来我想将它们显示为图表中的点。或者有没有办法从字段到图表显示字符串点?



有人有建议吗?



感谢..非常感谢





什么我试过了:



寻找类似的艺术品,msdn,google



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

推荐答案

你必须将点作为整数(或浮点数)存储在数据库中,具体取决于您正在使用的UI框架。您将需要X,Y,Width和Height的字段,以及识别给定按钮的方法。
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.


这篇关于从texrtfile到SQL数据库的转移点(点数字段)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆