|
|
Hi guys,
im using foreach to load some data from sqlserver and make appointmens from them in MS Outlook.
Something like this:
<br />
foreach (DataRow dr in dt.Rows)<br />
Bud the problem is that wen there are for example 2 rows in my DataTable, it most create 2 appointments, bud i see that the Seconde appointment always re-writes or removes the First one and then i see only 1 appointment in outlook.
Can somebody help me with this???
thanx
|
|
|
|
|
Can you provide a bit more code to what you are trying to do?
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Hi Paul Conrad,
Thanx for your response. Here some code of how it is looking like :
Outlook.Application outlookApp = new Outlook.Application();<br />
Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem);<br />
<br />
<br />
SqlCommand start = new SqlCommand("SELECT Act_actualstart,Act_actualstarttime FROM Activities WHERE Act_imp_nr='" + nr + "'and Act_Hoofdactiviteit_index='" + hfdnr + "'and Act_nr='001'", myconn);<br />
SqlDataAdapter da_start = new SqlDataAdapter(start);<br />
DataTable dt_start = new DataTable();<br />
da_start.Fill(dt_start);<br />
<br />
foreach (DataRow drstart in dt_start.Rows)<br />
{<br />
subject = "Communicatie naar; " +nr +"; " + omschrijving ;<br />
outStart = new DateTime();<br />
outStart = Convert.ToDateTime(drstart[0].ToString());<br />
oAppointment.Start = outStart;<br />
<br />
outEnd = new DateTime();<br />
outEnd = Convert.ToDateTime(drstart[1].ToString());<br />
<br />
oAppointment.End = outEnd;<br />
oAppointment.Subject = subject;<br />
oAppointment.Body = body.ToString();<br />
oAppointment.Location = " ";<br />
<br />
oAppointment.ReminderSet = true;<br />
oAppointment.ReminderMinutesBeforeStart = 5;<br />
oAppointment.Importance = Outlook.OlImportance.olImportanceHigh;<br />
oAppointment.BusyStatus = Outlook.OlBusyStatus.olBusy;<br />
oAppointment.Save();<br />
}
|
|
|
|
|
Djavid j wrote: SqlCommand start = new SqlCommand("SELECT Act_actualstart,Act_actualstarttime FROM Activities WHERE Act_imp_nr='" + nr + "'and Act_Hoofdactiviteit_index='" + hfdnr + "'and Act_nr='001'", myconn);
Off topic, string concatenation for queries is very dangerous. Look up Colin Mackay' article on this site about SQL Injection Attacks and why parameterized queries are a good idea.
How many records is the dataset filling?
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Hi,
There is one dataset. Bud i think that in this case the sqlcommand is not the problem, because i did a check:
everytimne that a appointment is made, i get a message: appointment made succfully.
And in this case i have to datarows, so i get two times the message, and e checked that ofter the first time i got the 'appointment made succesfully' i saw the first appointment in Outlook. bud wen i click on ok on the messagebox i get the second message:'appointment made succesfully', then i see in Outlook that the first appointment is gone, there is only the second one.
(sorry for my english )
|
|
|
|
|
Djavid j wrote: i have to datarows, so i get two times the message
It looks as if maybe your oAppointment.Save(); should be outside the foreach loop.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
this way it diffenatly wil make just one appointment
|
|
|
|
|
Shouldn't
Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem);
be inside the foreach loop? That way the loop creates a new appointment and saves it instead of overwriting the same object and saving it each time.
|
|
|
|
|
Yes that's the solution, thank you all, great help
|
|
|
|
|
I am having a data source containing millions of records. Is there any data controls (like datagrid/listview) which will bind the data acoording to the region visible to end user i.e. when the grid is scrolled, the data will be loaded & displayed
If you can suggest me any idea on developing a new component also will be helpful. I am thinking about overriding the WndProc method for the message WM_VSCOLL in a grid.
Thanks
*jaans
|
|
|
|
|
As Led Mike explained in the topic just below this, a virtual ListView will do exactly that. Here's a link: [^]
|
|
|
|
|
Thanks Alan.
I have posted my query without reading the latest thread
*jaans
|
|
|
|
|
Hi,
I'm trying to create a ListBox that will only get the items that are currently visible. There could be up to millions of items, so storing them all simultaneously is slow and inefficient.
I tried setting the ListBox's DataSource to a custom object that implements IList, but when I do this, it immediately requests ALL the items.
I tried changing the DrawMode to OwnerDrawFixed, but it exhibits the same behavior.
Can anyone suggest a way of making the ListBox only request the items it's drawing, short of reimplementing it myself? Thanks!
|
|
|
|
|
Why don't you use paging?
Ah and, are you having milions of items in ListBox?
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
That is called Virtual Mode. I don't think ListBox has that but you should be able to satisfy your requirements by using the ListView which does have a Virtual Mode.
led mike
|
|
|
|
|
Thanks Led Mike! That's just what I needed. In case anyone else has a similar problem, I found this article which explains how to use a virtual ListView: [^]
modified on Thursday, January 24, 2008 11:22:37 AM
|
|
|
|
|
FYI, here's a link to the next ListView article. (There's no link in the first article.) [^]
|
|
|
|
|
Hi all,
I'm trying to write some code to upload files from the machine where the windows application is installed to a server, for example from "C:\MyFolder\file.wav" to "http://ip/Project/folder/file.wav".
I tried:
WebClient objClient = new WebClient();
objClient.UploadFile(ServerURL, LocalFile);
but it always give me this exception:
An exception occurred during a WebClient request.
InnerException = {"Unable to write data to the transport connection: An established connection was aborted by the software in your host machine."}
Any idea?
Thanks.
|
|
|
|
|
Is a firewall blocking the port?
|
|
|
|
|
how can i be sure of this? i don't have firewall installed!!
|
|
|
|
|
If you don't have a firewall installed, the windows firewall is probably running. Look in the security center on the control panel, and see if the windows firewall is running. If so, add the port you are using to the exclusions list and try it again.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Hi,
I am using a ListBox on my form. My ListBox.Items property (which is ObjectCollection) contains objects of my-defined class type, whose ToString() methods are overriden. As I know, a ListBox calls the ToString() method of each item in its Items property to build a "string" to display. When adding a new object item ot Items affects display strings as a result.
So far everything is good and reasonable. The problem is that, when I MODIFY an object's content held by ListBox.Items, I expect the ListBox control redraw its content. Cause my modification affects the overridden ToString() method of an object of ListBox.Items. So I expect that the ListBox control to change display string of related object.
Unfortunately it does not work even if I have tried to call ListBox.Refresh(), or Update() method. Any other method I should call or my way thinking about ListBox.Items and displaying mechanism is wrong?
|
|
|
|
|
Maybe my thinking here is wrong, but how about simply clearing the listbox and re-add your object collection?
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Ok, thanks. I have just tried and it works.
|
|
|
|