Click here to Skip to main content
15,885,717 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Please help me to store and retrieve points multiple points in a varchar in database in c# form.


I get multiple points as input like
SQL
X=30,Y=60
X=20,Y=40
X=70,Y=160

and I have to store them in database and retrieve them but the constraint is that I will not have always these 3 points the points can be 3 points or 4 points or 5 points...

Hence retrieve them from database and then convert to point again

Please help to solve this
Posted
Updated 9-Feb-14 15:19pm
v2
Comments
CHill60 9-Feb-14 15:10pm    
What have you tried? Where are you stuck?
Kornfeld Eliyahu Peter 9-Feb-14 16:04pm    
It sound like some utterly wrong design, like to harvest with cannon just because we got a cannon in hand...
Can you explain more on the behind of the desired solution?
Sergey Alexandrovich Kryukov 9-Feb-14 19:21pm    
Why? why?!
—SA
BillWoodruff 10-Feb-14 4:09am    
See if this gives you some ideas:

http://stackoverflow.com/a/19872005/133321

To serialize/deserialize with JSON, I suggest you see Mehdi Gholam's fastJSON here on CodeProject:

http://www.codeproject.com/Articles/159450/fastJSON

1 solution

Regular expressions can help to parse some strings. So, from this question, it looks like you want to store some strings in database, and parse them to get some structured data which includes some numeric data.

This approach is badly, fundamentally wrong. It's hard to tell why, but one of the biggest common-place fallacies of many beginners these days is the trend to work with strings representing data, instead of data itself. This is especially typical for databases. You need to store elements of primitive types representing data structures in separate tables, using specific data types, numeric for numeric data, date for date/time data, and so on.

Working with structural data and appropriate design takes understanding of relational model, and, in particular, normalization:
http://en.wikipedia.org/wiki/Normalization_%28database%29[^],
http://en.wikipedia.org/wiki/Relational_model[^].

—SA
 
Share this answer
 

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