|
Thanks Mika. That should do it.
TD
|
|
|
|
|
No problem. Just a minor correction. It isn't actually SQL you're using but LINQ[^]. Although the syntax is somewhat similar, the concept is very different.
|
|
|
|
|
I was given a service application that manages (creating/deleting) the partitions on database tables. Currently at the top of every hour, the progam adds a new partition & deletes any partitions that are older than 36 hours. I am being asked to modify this so that on startup the application creates 36 paritions for each of the tables. Then at the top of every hour, it will create a new parition for time + 36hrs and again delete anything older than time-36hrs. A timer is used (with a 30 second interval) to check if it is the top of the hour.
I have 2 questions.....
1. I created a flag and set it to true on startup. Timer tick sub routine checks the flag, if it is True, the app loops through each table and creates 36 paritions, then sets the flag to False. Every time there after, the timer tick routine checks the minute property of the current time and if it is 0, runs the routine to create the new partition and delete the old. Is this the most efficient way to do it. I was reading about custom actions for setup projects and was thinking that maybe the first 36 could be created using this.
2. The timer tick every 30 seconds to check the minute property but I was wondering if there was a better way to check for the top of the hour.
Thanks in advance
|
|
|
|
|
I would guess that your timing system is efficient enough considering the task you'r doing. Creating and deleting partitions isn't a small job for the database engine.
Just a question: You didn't say what database you're using, but if it is SQL Server, why wouldn't you create a job under SQL Agent. You could do the programming using T-SQL thus eliminatig roundtrips to database. Also the database wouldn't depend on any service outside the SQL Server itself. For example if your service is stopped, halted etc, your database wouldn't act as expected. Also I believe that both the performance and maintainability would increase.
|
|
|
|
|
thanks for your response.
To answer your question, I am using Oracle 10g enterprise. Is there something in Oracle like the SQL Agent you were talking of. I do not have much experience using db, i was just handed this so I am kinda shooting from the hip.
Thanks again
|
|
|
|
|
captainmogo wrote: Is there something in Oracle like the SQL Agent you were talking of.
Yes, actually there are a few methods you can use, but I think that the most suitable could be that you use DBMS_SCHEDULER package. It can schedule a job with a given interval. You can find it in documentation in book named "PL/SQL Packages and Types Reference".
But before going into details, have a look at this article: Schedule Away the Routine[^]. I think it describes well the basic concepts of the scheduler.
Hope it helps,
Mika
|
|
|
|
|
I am trying to change a name of a worksheet.
Currently using ...
Sheets("RDC.d").Select<br />
Sheets("RDC.d").Name = "RDC"
However, the sheet RDC.d is produced from a secondry source and the name changes each time it is requested.
(The RDC part is consistant, the .d may be .g, .h etc)
How do I generically change the worksheet to RDC?
I may point out that the only sheets active will be the Mastersheet I am working in and this report sheet RDC.x
I have tried activating the report sheet...
Sheets(1).Select<br />
Sheets(1).Name = "RDC"<br />
<br />
But this is not working.
Any suggestions?
------------------------------------
"The greatest tragedy in mankind's entire history may be the hijacking of morality by religion"
Arthur C Clarke
|
|
|
|
|
OK Don't Bother
I just sussed that I was right and wasn't asking it to do what I wanted it to do!
Memo to self...READ WHAT YOU TYPE!
------------------------------------
"The greatest tragedy in mankind's entire history may be the hijacking of morality by religion"
Arthur C Clarke
|
|
|
|
|
Hi experts,
Here is an another problem of mine.
I have created a process using
dim p as new process
p.startinfo.filename="calc" 'or notepad
p.start()
Now,my problem is when I run the process the second time, it opens a new exe. That problem can be solved by raising an event. But, I want to MAXIMIZE the exe on top of all window ,if an instance is already running.(we can see the running process in taskbar, but my taskbar is also disabled for some reason, so i want it to get it top of my application with the help of code)
Since my main window doesn't have any close/minimize/maximize button, I want to show the user already running process by bringing the exe on top of my main form.
Could anyone give a solution please.
Thank you in advance.
|
|
|
|
|
Why would you want to prevent 2 calculators from being opened? Or two of anything? At any given time I have a good 7 or 8 notepad's open.
|
|
|
|
|
Member 4250705 wrote: Hi experts,
I'm not sure anyone here would want to lay claim to being an 'expert'.
ex - signifies a has been
spert - well a spurt is a drip under pressure.
You might want to try "Hi oh exalted gurus."
Much better.
Henry Minute
If you open a can of worms, any viable solution *MUST* involve a larger can.
|
|
|
|
|
Member 4250705 wrote: Hi experts,
I prefer, "Your Eminence" myself, but, whatever...
Member 4250705 wrote: Now,my problem is when I run the process the second time, it opens a new exe
OK, so keep the process in a class global variable and check to see if it's Nothing and check to see if it's HasExited property is True before you try to launch another copy.
Also, to maximize the window of another process, you have to send the MESSAGE to the app's window. You can get the window handle to send the message to from the Process class's MainWindowHandle property. Then you just have to call the Win32 API function SendMessage with the window handle and the message. You can get a code example on SendMessage from PInvoke.net[^].
The two constants for the WM_SYSCOMMAND and SM_MAXIMIZE message are:
Private Const WM_SYSCOMMAND As Integer = 274
Private Const SC_MAXIMIZE = 61488
Private myProcess As Process = Nothing
...
If myProcess Is Nothing OrElse myProcess.HasExited Then
myProcess = New Process()
myProcess.StartInfo.Filename = "calc"
myProcess.Start
Else
''' This is where you would send the message to the main window
''' to maximize the window.
End If
You'll have to do some more work to account for the case of the Process exiting, but this should be enough to get you started.
|
|
|
|
|
Thanks a lot for your advice
|
|
|
|
|
thanks a lot...
Could u please tell me how to send a message to maximize to the main window...
Else
''' This is where you would send the message to the main window
''' to maximize the window.
Thanks
I am a learner Always
|
|
|
|
|
Well, it's not really a message as it is a function call to send one. You need the main window handle property of the process you lanuched, then you use that to call ShowWindow[^].
|
|
|
|
|
Hi to All ,
Could anyone help me please , how to take a back up for Ms Access database using vb.net coding...
Note that I am doing this from same application which is using the database. I think it shouldn't give a problem since during taking the backup I am not doing anything else with the database.
Thanks in advance
|
|
|
|
|
An ms access database is just a file so in order to back it up you can just copy the file.
The system.io.file namespace can help you with that.
|
|
|
|
|
You can simply copy the file, but if it is in use at the same time, there's a slight risk that the copy isn't consistent.
You can also use DBEngine.CompactDatabase Method[^] via Microsoft Access Object Library (add reference to it). The starting point is Access.Application[^] object which you can create using COM interop.
|
|
|
|
|
Image processing
I am working on a Vb.net 2005 Express application where I need to compare the color of a image with the reference colors.
What I am planing to do is
- take some pixels from the image
- compare them with the reference colors
- do it for more then one pixels from a area of picture
- decide weather the shade is light or dark
Is this the right approach and how do I do some thing like this ?
The other things I need to know
I am interested in finding the shade of the color so the the user can get a output some thing like light, dark or medium ... how do I find that the given color is in which gradient range of that shade
Regards
Nishkarsh
|
|
|
|
|
nishkarsh_k wrote: Is this the right approach
That depends on what you want to accomplish...
nishkarsh_k wrote: how do I do some thing like this ?
Load the image into a Bitmap object and use the GetPixel method.
nishkarsh_k wrote: I am interested in finding the shade of the color so the the user can get a output some thing like light, dark or medium ... how do I find that the given color is in which gradient range of that shade
Look at the GetBrightness method of the Color class.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
So I have to do some code in VBA (if only it was .Net I wouldnt be here!) to get a list of all the groups a COMPUTER object is in from Active Directory. I can do this easily with ADS and a user, but the IADsComputer object does not have groups with it. Any idea how I could do this? The following works for users (in Excel)
Sub testHarness()
'Dont forget to add reference to Active DS Type Library
Dim usr As ActiveDs.IADsUser
Set usr = GetObject("WinNT://<domainname>/<username>,user")
For Each oGroupIn usr.Groups()
ActiveCell.Value = oGroup.Name
ActiveCell.Offset(1, 0).Select
Next
End Sub
I would think that the following would work for Computers, but alas it does not . I have been hunting for examples all day, but I can only find .net ones (which all work perfectly!)
Sub testHarness()
'Dont forget to add reference to Active DS Type Library
Dim srv As ActiveDs.IADsComputer
Set srv = GetObject("WinNT://<domainname>/<servername>,computer")
For Each oGroup In srv.Groups()
ActiveCell.Value = oGroup.Name
ActiveCell.Offset(1, 0).Select
Next
End Sub
Or do I need to do this completly differently?
(And I really hope this is the right forum for VBA, I couldnt see anything else)
modified on Tuesday, January 13, 2009 7:05 PM
|
|
|
|
|
I have found the answer, based on this post - http://www.tek-tips.com/viewthread.cfm?qid=1245332&page=1[^]
My resulting code now looks like this, in case anyone else is interested:
Sub TestHarness
Set objTrans = CreateObject("NameTranslate")
objTrans.Set 3, "<domainname>\<servername>$"
strComputerDN = objTrans.Get(1)
Set objComputer = GetObject("LDAP://" & strComputerDN)
colGroups = objComputer.MemberOf
For i = 0 To UBound(colGroups)
ActiveCell.Value = GetGroup(colGroups(i))
ActiveCell.Offset(1, 0).Select
Next
End Sub
Function GetGroup(strGroup) As String
z = Split(strGroup, ",")
If Left(z(0), 3) = "CN=" Then
GetGroup = Right(z(0), Len(z(0)) - 3)
Else
GetGroup = ""
End If
End Function
|
|
|
|
|
Hi,
Actually i am creating some graphic using SYSTEM.DRAWING namespace in vb.net now every thing is going fine but i Want o make that file as read only means no body can change it in either paint or any else tool.This can be achieved by
System.IO.File.SetAttributes("c:\test.jpg", IO.FileAttributes.ReadOnly)
but doing this way user can change the attribute of file using file properties in windows Xp. I Need help to make the file readonly for ever can any body help me please..
|
|
|
|
|
You shouldn't and probably can't do this. A user owns the machine, or his privileges are set by an administrator that control this. Your application cannot and should not be able to do what you want for obvious reasons...
|
|
|
|
|
sarfarazaliqureshi wrote: I Need help to make the file readonly for ever can any body help me please..
Can't be done. Someone, most notably, an admin, will ALWAYS be able to revert it back to read/write, for any user.
|
|
|
|