Heading Here

how to store the coordinates (points) of a line as x0,y0 ,x1,y1 .....xn,yn in database MS SQL.

coding is in c#

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;

namespace WindowsFormsApplication6
{

    {
        List<Point> points = new List<Point>();
        class Line
        {
            public Point Start { get; set; }
            public Point End { get; set; }
        }

        public Form1()
        {
            InitializeComponent();
            var pb = new PictureBox { Parent = this, Dock = DockStyle.Fill };
            Line line = null;

            pb.MouseMove += (s, e) =>
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        line.End = e.Location;
                        pb.Invalidate();
                    }
                };
            pb.MouseDown += (s, e) =>
                {
                    if (e.Button == MouseButtons.Left)
                        line = new Line { Start = e.Location, End = e.Location };
                };
            var lines = new List<Line>();
            pb.MouseUp += (s, e) =>
                {
                    if (e.Button == MouseButtons.Left)
                        lines.Add(line);
                };
            pb.Paint += (s, e) =>
                {
                    if (line != null)
                        e.Graphics.DrawLine(Pens.Red, line.Start, line.End);

                    foreach(var l in lines)
                        e.Graphics.DrawLine(Pens.Silver, l.Start, l.End);
                };
        }

        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            if (points.Count > 1)
                e.Graphics.DrawLines(Pens.Magenta, points.ToArray());
        }

        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                points.Add(e.Location);
                pictureBox1.Invalidate();

            }
        }


    }
}
    public partial class Form1 : Form

MS SQL has two data types, geometry and geography, which are designed for holding that type of data. Define your columns using them. And read the docs, there's a lot more to it than just that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.