Hello,
i am a bit experienced with C#, i know what everything means and what is does and stuff :D
But I'm making a windows forms application now with lots of textboxes.
What i want is that when the user presses a "save" button(already got the button :P), the inserted strings in the texboxes are saved and can be loaded on next use.
Can anyone explain how i can do that? I think it is very easy, but i just don't know how :)
So all i need to know, is what is the C# code to save all inserted text and load it on next use.
Many thanks in advance,
Rick
Loading

Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 6, 2011, 12:50 PM EDT
If you do not have database installed on your machine I would suggest to install SQL Server Express Edition on your machine, following is the link:
http://www.microsoft.com/download/en/details.aspx?id=1695
After you have installed the above then you can install the Management Studio Express which will allow you to create database, tables and stored procedures easily, following is the link:
http://www.microsoft.com/download/en/details.aspx?id=8961
Follow this link to create a database:
http://msdn.microsoft.com/en-us/library/ms186312.aspx
Follow this link to create the tables in that database, be certain of your storage needs when you are creating the tables:
http://www.ehow.com/how_5877415_create-tables-sql-management-studio.html
Follow this link to create the stored procedure which will help us do the database insert/update/delete etc from our c# application:
http://msdn.microsoft.com/en-us/library/ms345415.aspx
Let me know if you need more help in this and once you are done we can run the code from .cs file.
alternatively there are a lot of article/books available which will teach you from the basic.
Please do not forget to mark "Accepted Answer".
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 6, 2011, 12:10 PM EDT
Rick van Leeuwen37 reputationPosted Oct 6, 2011, 12:15 PM EDT
all i want is just that the numbers that the user typed in the textboxes are there again when you close and open the application again.
i dont care how, because i dont know anything about either way :D
Rick
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 6, 2011, 12:22 PM EDT
Please do not forget to mark "Accepted Answer".
Rick van Leeuwen37 reputationPosted Oct 6, 2011, 12:30 PM EDT
all i have is the form with the textboxes and button :)
i never used database
do i have to put that code in my program.cs, and if yes where?
can you explain to me or is it like a year learning to know it ?
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 6, 2011, 12:32 PM EDT
Rick van Leeuwen37 reputationPosted Oct 6, 2011, 12:39 PM EDT
I am new to C#, i am doing a Software Engineering Education which started this September
The things i mastered right now are only:
variables
simple maths (+,-,*,/)
if/for/while statements
methods
that's about it.
Now i am at home trying some stuff and wanted to make an application where i can insert the time i start working(i have parttime job beside education), when i stop and breaks and total and so on, but the maths will be no problem.
you think to complicated :). i just want when i press a save button, that the times i inserted in the textbox are remembered for when i start the app next time.
I hope this will help you helping me :D
Rick
Rick van Leeuwen37 reputationPosted Oct 6, 2011, 12:53 PM EDT
Thanks again
Rick
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 6, 2011, 12:59 PM EDT
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 7, 2011, 6:50 AM EDT
Rick van Leeuwen37 reputationPosted Oct 7, 2011, 7:10 AM EDT
but now i have other problem
i installed the sql server management studio express to,
Now it asks server name, what is the server name?
i tried the name i gave to my sql server (called it MYDATABASE) but that wont work
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 7, 2011, 7:19 AM EDT
1. Your Machine name
2. localhost
3. . (just a dot)
Rick van Leeuwen37 reputationPosted Oct 7, 2011, 8:28 AM EDT
But now it says it can only connect to sql 2000 and 2005 servers :(
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 7, 2011, 8:32 AM EDT
open the sql management UI and show me the screenshot on how it looks, can you right click and create a new database?
Rick van Leeuwen37 reputationPosted Oct 7, 2011, 8:34 AM EDT
i just have to be able to login there to proceed with your tutorial few posts back (i just installed the one you linked me)
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 7, 2011, 8:39 AM EDT
Rick van Leeuwen37 reputationPosted Oct 7, 2011, 8:46 AM EDT
when i try to login with either
localhost
.
or computername,
i get this
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 7, 2011, 8:56 AM EDT
http://www.microsoft.com/download/en/details.aspx?id=9969
Rick van Leeuwen37 reputationPosted Oct 7, 2011, 9:10 AM EDT
i have a simple offtopic question
how can i subtract time? (inserted in textbox)
like 16:00 - 10:00
i tried things like:
convert.ToDateTime
and
DateTime time = NewDateTime()
VulpesRank #55 · 29.2K reputationPosted Oct 7, 2011, 9:44 AM EDT
DateTime dt1 = DateTime.Parse(textBox1.Text);
DateTime dt2 = DateTime.Parse(textBox2.Text);
TimeSpan ts = dt2 - dt1;
double hours = ts.TotalHours;
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 7, 2011, 10:54 AM EDT
TimeSpan ts = date1.Subtract(date2); // both are DateTime
Sam HobbsRank #107 · 20.5K reputationPosted Oct 7, 2011, 8:40 PM EDT
It is good to learn about databases, but if I had been able to see this thread earlier, I would have make the suggestion earlier.