|
Hi,
I'm using Access on Vista with OLEDB
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+file+";User Id=XXX;Password=YYY;";
Every constr you ever needed[^] is here.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
That's what I was using when I migrated the project to my new development box, but it says that it can't find the Jet provider. Research on Google says that you can't use Jet in Vista; the installer won't even install it. How did you set it up?
|
|
|
|
|
I don't recall there being any issue.
I installed Access2003, Visual Studio, and lots of other stuff on a Vista Home Premium machine.
Then created a C# app that works on an existing mdb file.
What installer is complaining? and what is its message?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I don't kown why..., but when I adding attachment (Bitmap) from MemoryStream, it dosn't work, because I receive mail with picture, but it has 0 KB. Bitmap adding as attachment from FileStream, work correctly... (sorry, my bad english)
thanks
Here is my snippet code:
...
Bitmap bmp;
...
MemoryStream = new MemoryStream();
bmp.Save(memStream, ImageFormat.Jpeg);
...
ContentType contentType = new ContentType();
contentType.MediaType = MediaTypeNames.Image.Jpeg;
contentType.Name = "screen";
MailMessage mail = new MailMessage();
...
mail.Attachments.Add(new Attachment(memStream, contentType));
...
SmtpClient.Send(mail);
|
|
|
|
|
I don't see where you are even getting the bitmap?
Bitmap bmp; <---- Empty
MemoryStream memStream = new MemoryStream(); <--- Empty
bmp.Save(memStream, ImageFormat.Jpeg); <---- Still Empty
Where are you actually getting the bitmap data from? As far as I can see that is why it is 0kb because you are not giving it any data
|
|
|
|
|
shouldn't you "rewind" the stream?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
In memory buffer, there is a snap shott from screen.
This code is not completly, if i try save image from memory buffer to file.. it's ok
|
|
|
|
|
did you try memStream.Position=0; // rewind ?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
now I try it, but nothing
MemoryStream memStream = new MemoryStream();
memStream.Position = 0;
bmp.Save(memStream, ImageFormat.Jpeg);
|
|
|
|
|
Have a cup of coffee, then do the rewind after saving the image.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
omg.. very very thanks..
|
|
|
|
|
Thank you! Was having the same problem.
|
|
|
|
|
This might be a simple answer but I cannot seem to think of it. What would be the best way to send reports every monday at 7am. I guess what I am asking what is the best way to determine the time is 7am and send the report?
Run a timer every second and if the day is Monday and the time is exactly 7:00am send it? Or is there a better way I am just not thinking of?
|
|
|
|
|
Create a console executable and schedule it using windows task scheduler. You can also go for a scheduled windows service but there are opinions that "services are not meant to be scheduled".
जय हिंद
|
|
|
|
|
I forgot to mention that this was going to be a Windows Service
|
|
|
|
|
then use a timer; however don't rely on exact timing, you might miss a start if the system happens to be busy.
Instead use a time window, and check the current date is different from the date it ran last.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Make sure you handle the case where the machine may be rebooted or your service restarted, even during the reporting time window.
|
|
|
|
|
This seems the most simple way... basically set the windows scheduler to run the application at certain times. I like it... I will give it a try
|
|
|
|
|
Use a timer.
1- Calculate the amount of time until 7am.
2- Set a timer to wake you up when that amount of time has passed.
3- When the timer wakes you up, do your stuff.
4- Goto 1.
Go with D@nish's suggestion, much better.
|
|
|
|
|
Firstly - I'd set up some method by which each report can be scheduled to be run and/or sent at a different time (because that's bound to be a requirement in the future!)
Get your collection of scheduled times and convert them to 'next run Date Times' sorted in ascending order. Remember you will need some way of telling when a report was last run, too, so that a report scheduled for 7:00 does not also get run at 7:01)
Calculate teh time from NOW to the first entry in your list. Set a timer for this duration (less a short amount to cater for discrepancies.
Decide whether you will allow new reports to be added into the current schedule between NOW and the next scheduled report time, or reports to be removed from the schedule. (if you do, you need some polling to detect a change, and restart the algorithm .
On 'waking' re-build the collection (in case something has changed). If the next scheduled report is due (or past due) run it, and update it's 'Last Run' date/time then re-create the collection (catch multiple reports scheduled simultaneously).
You need to decide (assuming you implement the polling mentioned above) how time critical you need it to be. If +- 5 minutes is going to be OK - then your polling can be once every five minutes (remembering that your polling should probably be paused while any report is in progress)
Hint for young players; When I had somethinglike this implemented a few years ago, the developer created the list of reportsw by selecting WHERE ScheduledTime > TimeRightNow - this doesn't work if the time the report is scheduled for has passed (because, for example, teh previous report took a long time to run) - you need to include rpeorts based on whether the report has been run for the last scheduled time, not whether that time has passed.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Maxxx,
Thats for your advice. Although I think that is getting a little too complex for me right now. Maybe its late.. I dunno.
I think right now.. the easiest solution for me is the console application. Although I much rather do a Windows Service so I can learn to use it more, I will try this right now...
Maybe if I had a close example of your suggestion.. like an article or something I could read to better understand how exactly you see it working.
|
|
|
|
|
What if I did this?
There is only one email I want to send at (or around) 7 am on Monday mornings.
So what if i set a boolean to false
private bool Ran = false;
Then on timer tick (every 2 minutes)
private void timerReport_Tick(object sender, EventArgs e)
{
if (DateTime.Today.DayOfWeek == DayOfWeek.Monday)
{
if (!Ran)
{
PrepareReport();
Ran = true;
}
}
else Ran = false;
}
Basically every time the timer ticks and the day isn't Monday, it says Ran to false. Meaning that it hasnt Ran.
So if the day IS Monday and the boolean is FALSE, then it prepares and sends the report, then sets RAN to true.
So RAN wouldn't get set to FALSE until the day isn't Monday...
What do you guys think about this?
Waste of resources?
|
|
|
|
|
That would run your report at 00:02 (or there abouts) on monday and, if you don't persist the 'ran' status somehow, won't work if the program is stopped for any reason (if it is restarted on a Monday you would always get another copy of the report).
Maybe..
timer.Stop();
if (!ran && DateTime.Today.DayOfWeek == dayToRun && DateTime.Now.TimeOfDay >= timeToRun)
{
PrepareReport();
ran = true;
}
timer.Interval = MillisecondsBeforeTimeToRun();
ran = false;
timer.Start();
Then you write MillisecondsBeforeTimeToRun() to calculate how long between now and the next time you want to test for the report being run.
Simplest case - if today is report day and the report has not been run, it's the difference between the time right now and the report time.
If the day is report day and the report has been run, it's 6 days from now plus the number of minutes until midnight from now, plus the report time.
If the day is not report day, you can safely leave it for (24 - now) + report time before checking again (or you can work it out accurately)
All this is obviously a bit pedantic - if you are just running one report once a week - I mean, the overheads of the polling every 2 mins are nothing - but it's nice to do these things 'properly'
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Hi there,
c#/.net n00b
I have an application that consists only of a NotifyIcon and a ContextMenu (not a menu strip) and I want to be able to "pop" the context menu to a particular option without mouse interaction. Is this possible?
The reason I want to do this is in my context menu I have a list of items that the user can choose to refresh, I'd like the context menu to pop back to the list of items after the refresh.
When I try to use the Show method it wants a Control and a Point.
Many thanks in advance!
|
|
|
|
|
I have been thinking about this... Having a submenu works well because I can capture the Popup event and refresh the contents before it is displayed. However I'd still like to make a refresh item that doesn't close the context menu. Or one that pops the menu back to where it was before.
Anyone have any ideas?
|
|
|
|