944,184 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 6173
  • C# RSS
Dec 7th, 2006
0

SQL Database loop

Expand Post »
Hello guys,


I have a Calendar control that I am working on. I am having problems with the appointment portion of it. Everytime you click on a time slot and type, it adds an appintment. Here is the code I use to add the appointment.

 
Appointment m_Appointment = newAppointment();
m_Appointment.StartDate = m_Date;
m_Appointment.EndDate = enddate;
m_Appointment.Title = "test";
m_Appointments.Add(m_Appointment);

Right now I have the appointments saved to a database that I have entered. The only problem is that after the program closes it doesnt save the appointments but they are in the database.

Is there a way to get the appointments at the start of the program?

I was thinking about getting the number of records int he database and put it in the interger "records" and then do a for loop to to add the appointments until the end of the records is complete. something like this.

 
for (int i = 0; i < records; i++)
{
 
 
Appointment m_Appointment = newAppointment();
m_Appointment.StartDate = m_Date;
m_Appointment.EndDate = enddate;
m_Appointment.Title = "test";
m_Appointments.Add(m_Appointment);
 
}

This will add them back to the form on start but how do I specify what StartDate, EndDate and Title are for each iteration through the records? I am kinda new to SQL.
Last edited by chuck577; Dec 7th, 2006 at 6:33 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chuck577 is offline Offline
15 posts
since Oct 2006
Dec 7th, 2006
0

Re: SQL Database loop

I did a little more research and found that I was going about this all wrong. I am going to use a DataSet and that should do what I need done here.

Thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chuck577 is offline Offline
15 posts
since Oct 2006
Dec 8th, 2006
0

Re: SQL Database loop

Click to Expand / Collapse  Quote originally posted by chuck577 ...
I did a little more research and found that I was going about this all wrong. I am going to use a DataSet and that should do what I need done here.

Thanks
another option could be simply running a select statement to grab what you need since you are working with a SQL database.

if you need a specific start date /end date that depends on the SQL server but the generic and commonly excepted way could be

select [some column],[somecolumn],[somecolumn]...etc
from [name of database]
where [name of date column] between 'dd-mmm-yyyy' and 'dd-mmm-yyyy';

my syntax may be off though.
Last edited by Killer_Typo; Dec 8th, 2006 at 4:36 am.
Reputation Points: 152
Solved Threads: 39
Master Poster
Killer_Typo is offline Offline
778 posts
since Apr 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: HELP~! how to call Matlab function in C#?
Next Thread in C# Forum Timeline: How can i solve the COMException problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC