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 ShaikhPosted Oct 6, 2011, 4:50 PM
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".
Sam HobbsPosted Oct 8, 2011, 12:40 AM
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.
Javeed M ShaikhPosted Oct 7, 2011, 2:54 PM
TimeSpan ts = date1.Subtract(date2); // both are DateTime
VulpesPosted Oct 7, 2011, 1:44 PM
DateTime dt1 = DateTime.Parse(textBox1.Text);
DateTime dt2 = DateTime.Parse(textBox2.Text);
TimeSpan ts = dt2 - dt1;
double hours = ts.TotalHours;
Rick van LeeuwenPosted Oct 7, 2011, 1:10 PM
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()
Javeed M ShaikhPosted Oct 7, 2011, 12:56 PM
http://www.microsoft.com/download/en/details.aspx?id=9969
Rick van LeeuwenPosted Oct 7, 2011, 12:46 PM
when i try to login with either
localhost
.
or computername,
i get this
Javeed M ShaikhPosted Oct 7, 2011, 12:39 PM
Rick van LeeuwenPosted Oct 7, 2011, 12:34 PM
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 ShaikhPosted Oct 7, 2011, 12:32 PM
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 LeeuwenPosted Oct 7, 2011, 12:28 PM
But now it says it can only connect to sql 2000 and 2005 servers :(
Javeed M ShaikhPosted Oct 7, 2011, 11:19 AM
1. Your Machine name
2. localhost
3. . (just a dot)
Rick van LeeuwenPosted Oct 7, 2011, 11:10 AM
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 ShaikhPosted Oct 7, 2011, 10:50 AM
Javeed M ShaikhPosted Oct 6, 2011, 4:59 PM
Rick van LeeuwenPosted Oct 6, 2011, 4:53 PM
Thanks again
Rick
Rick van LeeuwenPosted Oct 6, 2011, 4:39 PM
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
Javeed M ShaikhPosted Oct 6, 2011, 4:32 PM
Rick van LeeuwenPosted Oct 6, 2011, 4:30 PM
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 ShaikhPosted Oct 6, 2011, 4:22 PM
Please do not forget to mark "Accepted Answer".
Rick van LeeuwenPosted Oct 6, 2011, 4:15 PM
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 ShaikhPosted Oct 6, 2011, 4:10 PM