|
If you have control over both ends, why use strings at all?
|
|
|
|
|
As an intermediate format without having to resort to serialization
Bastard Programmer from Hell
|
|
|
|
|
|
True, that's an option too
You can store every class by simply looping it's public properties, and to store the contents as a string. (Storing both ints in a string is the same thing) That would mean that you have to pay attention to the format, and match up the encode/decode functions.
The TypeConverter is a somewhat "safer" way of converting your class, because it adheres to a fixed format for that type in a human-readable form. It's not only used for locations, but also for colors and the like. This would be my recommendation.
A third option would be serialization. That'd be a bit overkill in this particular situation, but it remains an option.
Bastard Programmer from Hell
|
|
|
|
|
Well I was just going to store the ints and ints, but yea it really depends on where the data is supposed to go..
|
|
|
|
|
Eddy Vluggen wrote: You can store every class by simply looping it's public properties, and to store the contents as a string. Just curious: you mean by using Reflection ?
And, if I may ask, why would serialization be "over-kill" in this scenario ... assuming this question is not a one-off, but has broader implications.
And, how about using Mehdi Gholam's zippy implementation of JSON on steroids here on CP ? Over-kill ?
best, Bill
"Last year I went fishing with Salvador Dali. He was using a dotted
line. He caught every other fish." Steven Wright
|
|
|
|
|
BillWoodruff wrote: Just curious: you mean by using Reflection ?
That's what it implies, and yes, I know that you don't need reflection for serialization.
BillWoodruff wrote: And, if I may ask, why would serialization be "over-kill" in this scenario ... assuming this question is not a one-off, but has broader implications.
Because the TS gave an example where he'd convert a small structure to a string and back. If he had asked how to store a class or a collection, I'd answered serialization.
BillWoodruff wrote: And, how about using Mehdi Gholam's zippy implementation of JSON on steroids here on CP ? Over-kill ?
I'm not familiar with the article, but it sounds like a viable alternative.
Bastard Programmer from Hell
|
|
|
|
|
Typically the answer to this is if you want to store something in a human readable form. Object->string conversions are often part of file I/O. (This is what I'm using similar code for.) Or, for a web app, creating a POST request body, though there it might be better to use &x=42&y=72.
|
|
|
|
|
Ah yes of course, I was thinking too much in terms of persistence
|
|
|
|
|
Hey guys,really need some serious help with my capcha code project.My caphca code variation is that it has to consist of a number pattern and the user has to input the missing number
For eg. 2,4,6__,10 (Fill in the missing code)
I already have the graphics class setup ,so just the code for randomly generating a number pattern itself.Please Help guys.I'm a beginner programer.Help much appreciated.
|
|
|
|
|
What sorts of pattern do you want?
Once you successfully answer that question (defining the pattern types that are valid) it should be trivial to write it in code.
|
|
|
|
|
Show us what code you've got and indicate what the problem is, then maybe we can help.
Otherwise, look at recaptcha[^]
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
Hi Guys!
I am trying to make one simple application where i want to have info from db(Damain Z)
example:
I am in Damain X where the tool will reside,i have a bridge domain Y and a domain Z where DB resides..
any clue how to solve this senario!!!
vikas da
|
|
|
|
|
If these is no trust setup between Domain Z and Domain X, you're limited to using SQL Server accounts and SQL Authentication. The problem with this is maintaining the accounts on the SQL Server, seperate from everyones AD account.
|
|
|
|
|
Crystal report not open other system in 32bit window 7 AMD processor
and report related files............
thanks in advance.
|
|
|
|
|
Please clarify your question, and also explain why this is a C# issue.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi Guys,
I am having a problem here, please help.
I wanted to create an CAPTCHA image using text from SQL Database but now I don't know how to actually fit the get and fit the text in the image. I have already created the image but with automatically generated text using C# code.
I tested my program before, I got the image with the automatically generated text but now I dont get the other components like the textbox and botton for entering the text and validating it.
Please help!!! Thanks in advance!!!
|
|
|
|
|
Why? What you create will almost certainly not be as good or robust as those that are already available.
Have a look at ReCaptcha[^] - it's free, it's easy to use, and it helps digitise books that have failed OCR treatment.
[edit]Damn that link truncation bug! Fixed - OriginalGriff[/edit]
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
modified 24-Oct-11 4:32am.
|
|
|
|
|
Crappy link I do believe.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Fixed - it's the damn link truncation bug again. If you highlight text and then paste a link for some reason the url gets truncated in proportion to the original text length. But only sometimes, and most links get straight through. I reported it a month or so ago...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Hi
For my assignment, I need to find out all rows that were newly added into the datagrid and add it to the database.
I have pasted my code below, getting error in setting dRow where it says index is out of range.. I thought the newly added row can be accessed thru the index. Please let me know how to access the cells in newly added row.
public partial class AllCustomer : Form
{
private int ii;
public AllCustomer()
{
InitializeComponent();
string strConnection = "Data Source=.;Initial Catalog=Company;Integrated Security=True";
SqlConnection sqlconn = new SqlConnection(strConnection);
DataSet ds = new DataSet();
string sqls = "select * from CustomerMaster";
SqlDataAdapter da = new SqlDataAdapter(sqls, sqlconn);
sqlconn.Open();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
ii = dataGridView1.RowCount;
sqlconn.Close();
}
private void btn_Add_Click(object sender, EventArgs e)
{
string strConnection = "Data Source=.;Initial Catalog=Company;Integrated Security=True";
SqlConnection sqlconn = new SqlConnection(strConnection);
DataSet ds = new DataSet();
string sqls = "select * from CustomerMaster";
SqlDataAdapter da = new SqlDataAdapter(sqls, sqlconn);
SqlCommandBuilder cmdBldr = new SqlCommandBuilder(da);
sqlconn.Open();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
for (int j = ii; j >= dataGridView1.RowCount; j++)
{
DataRow dRow = ds.Tables[0].NewRow();
dRow["cust_name"] = dataGridView1.Rows[j].Cells["cust_name"].Value.ToString();
dRow["cust_st_addr"] = dataGridView1.Rows[j].Cells["cust_st_addr"].Value.ToString();
dRow["cust_city_state_zip"] = dataGridView1.Rows[j].Cells["cust_city_state_zip"].Value.ToString();
dRow["cust_phone"] = dataGridView1.Rows[j].Cells["cust_phone"].Value.ToString();
dRow["cust_stat_cd"] = dataGridView1.Rows[j].Cells["cust_stat_cd"].Value.ToString();
dRow["cust_add_dt"] = "2011-10-14";
dRow["cust_updt_dt"] = "2011-10-15";
ds.Tables[0].Rows.Add(dRow);
}
da.Update(ds.Tables[0]);
}
}
|
|
|
|
|
this is wrong.
1) In the button add click event you load the data form the DB again. Without first adding stuff
2) ii has the value of Count . Lets say 5. That means dROW[4] maximum and you start with 5.
The list could go on.
All the best,
Dan
|
|
|
|
|
I've visual c# 2008 ,I wanna make an assembly program of 8086 microprocessor on it,, is it available ????
could u show me the steps ,,plz??? thanks
|
|
|
|
|
Uhhh.. you're either asking how to write an 8086 emulator or your looking to write an app in Intel Assembly Language. I really can't tell which.
In either case, the required discussion would fill entire books. WAY too much information for a couple of forum posts.
|
|
|
|
|
Here[^] is an article that seems to explain things rather well, I didn't test it however I do expect it to work properly, even with Visual Studio C++ Express. What it doesn't say is you will be getting some build errors, unless you move some switches away from their default values. Trial and error will be involved.
[ADDED]
ML.exe may already be present in C:\Program Files\Microsoft Visual Studio 9.0\VC\bin
Now how is this a C# question?
[/ADDED]
modified 22-Oct-11 19:41pm.
|
|
|
|