|
AWESOME
IntPtr hWinSta = GetProcessWindowStation();
WindowStationSecurity ws = new WindowStationSecurity(hWinSta, AccessControlSections.Access);
ws.AddAccessRule(new WindowStationAccessRule("user@domain", WindowStationRights.AllAccess, AccessControlType.Allow));
ws.AcceptChanges();
IntPtr hDesk = GetThreadDesktop(GetCurrentThreadId());
DesktopSecurity ds = new DesktopSecurity(hDesk, AccessControlSections.Access);
ds.AddAccessRule(new DesktopAccessRule("user@domain", DesktopRights.AllAccess, AccessControlType.Allow));
ds.AcceptChanges();
Did the trick. Thank you veeery much for pointing me to this.
Cheers
Guido
|
|
|
|
|
Thank you, for sharing your answer - bookmarked it for future reference
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Congratulations on a solution!
I was just looking at this again last night and didn't get anywhere.
|
|
|
|
|
I have a panel of size width=150 pixel,height=100 pixel, backcolor=green with autoscroll is true. I also have a picturebox within that panel which contains a picture of size width=500 pixel, height=200 pixel. I also have a button, on clicking that button picturebox image rotates 90 degree clockwise. and according to that scrollbar values should change. but it is not.
Here is my code
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim h, w
PictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone)
PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
h = PictureBox1.Image.Height
w = PictureBox1.Image.Width
Panel1.HorizontalScroll.Maximum = 0
Panel1.HorizontalScroll.Visible = False
Panel1.VerticalScroll.Maximum = 0
Panel1.VerticalScroll.Visible = False
Panel1.AutoScroll = False
Panel1.HorizontalScroll.Minimum = 0
Panel1.HorizontalScroll.Maximum = w - 1
Panel1.HorizontalScroll.Visible = True
Panel1.HorizontalScroll.Value = 0
Panel1.VerticalScroll.Minimum = 0
Panel1.VerticalScroll.Maximum = h - 1
Panel1.VerticalScroll.Visible = True
Panel1.VerticalScroll.Value = 0
Panel1.AutoScroll = True
PictureBox1.Left = 0
PictureBox1.Top = 0
Panel1.Invalidate()
End Sub
My problem is: On form load both the scrollbars working perfectly. But after clicking the button picturebox rotates to 90 degrees, so picturebox's images's width and height values interchanges, so the scrollbars maximum values. But its not. After clicking the button first time vscrollbar does not go down after a certain value. This thing happens on odd number of clicking the button. On even number of clicking it works perfectly.
This odd and even number problem also interchanges when the original picturebox image dimension interchanges. i.e. when picturebox image width=200, height=500, then hscrollbar creates the problem on odd number of button clicking.
|
|
|
|
|
The PictureBox is not perfect and if you turn on the borders you should be able to see that it does not resize itself correctly after the image has been rotated. In theory PictureBox.Refresh() or PictureBox.Invalidate() should sort out any problems but in my experience those methods do not help and the picturebox does not seem to know that the image has rotated. What I found helpful was to simply reassign the rotated image to the PictureBox.Image property.
The strange alternate click issue with the Panel's scrollbars tends to happen if you muck about with the scroll properties. I came to the conclusion that Microsoft never meant us to change them!
Alan.
|
|
|
|
|
Hello
Hope it's ok to post this here - it's a general programming query but maybe it should be in "Database"? Anyway...
I've never really understood database connection pooling...
If I want to make a lot of separate database updates I could take one of two approaches:
Do
run some code to prepare SQL command
Open DB connection
Run SQL command
Close DB connection
Loop Or
Open DB connection
Do
run some code to prepare SQL command
Run SQL command
Loop
Close DB connection
Which is the better approach?
Thanks...
|
|
|
|
|
Those aren't separate database-updates. Combine them, execute a single IDbCommand and wrap it in a transaction.
As for the loop; There's a good explanation on MSDN[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Well, I'm not sure to combine a number of statements of the form
insert into table (field1, field2,...) values (?,?,...) on duplicate key update field2 = ?, ... with associated command parameters into one.... (MySQL)
I guess I need to look into using transactions more....
thanks
|
|
|
|
|
A_Griffin wrote: Well, I'm not sure to combine a number of statements of the form In case of doubt, verify.
INSERT statements that use VALUES syntax can insert multiple rows. To do this, include multiple lists of column values, each enclosed within parentheses and separated by commas. I don't work with MySQL a lot, but in SQLite there is a very noticeable slowdown if you insert each record separately.
It looks a lot like a bulk-insert. If you don't want to import it in a single go, I'd still recommend doing it at least in batches.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes, for simple inserts MySQL can use bulk inserts as you suggest, but when combined with the "on duplicate key update" option then, as far as I know, this cannot be done.
|
|
|
|
|
|
Yes, thanks - it says nothing there about how (or even if one can) combine multiple such statements into one.
And why, out of interest, would you never use it?
|
|
|
|
|
A_Griffin wrote: Yes, thanks - it says nothing there about how (or even if one can) combine multiple such statements into one. It does, even comes with an example - and a note it might be unsafe.
A_Griffin wrote: And why, out of interest, would you never use it? Because I could not longer guarantee the integrity of the database, which is rather important to me.
What is your key? Let's take a VARCHAR(10) as an example key. There's already an entry "test" in your DB, and the same key occurs in your import-set 15 times. Which of those would you reckon to be the correct one? Which one do you think will be inserted? That may lead to some inconsistencies in a replication-scenario.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
The best solution is the one that minimizes the number of "new" connections made (which is extra overhead); and doesn't keep a connection open longer than needed (hogs resources).
In your case, the choice depends on the amount of "looping" and what "run some code" involves; so there is no "one answer".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Gerry Schmitz wrote: The best solution is the one that minimizes the number of "new" connections made (which is extra overhead); In doubt, open and closing has the preference. Thanks to connection pooling the overhead is limited.
There is a Dokan-implementation in the wild available that emulates a drive using a SQL server database. Opening and closing a connection for each request did not slow the machine down even a tiny bit.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you - that is interesting. I do wonder though, when you say "If in doubt..." - what doubt? Under what circumstances then would one prefer the other option (a single open/close outside the loop)?
|
|
|
|
|
|
Indeed, I could, but I don't expect a huge (or even noticeable) difference in performance with the size of databases I'm working with at the moment. I just wondered if one method was considered "best practice", really, and is maybe more scalable as the size of the database grows over time... MY gut feeling prefers, like you, to have each command wrapped in its own connection, but the other half of my gut (!) feels uneasy about opening and closing a hundred or so connections in such quick succession... it feels like a lot of unnecessary work. But if pooling is about minimizing this work, then good... (hence why I started off by saying I've never really understood (the guts) of pooling...)
|
|
|
|
|
A_Griffin wrote: but the other half of my gut (!) feels uneasy about opening and closing a hundred or so connections in such quick succession... After implementing a scenario where that actually happened, I'm not.
A Dokan-drive is something that shows up and acts like a drive in Windows Explorer (including any save-dialog), with the implementation of fetching the data left to the programmer. Clicking on a folder in Windows Explorer would launch a whole lotta operations - it would first want to know if there is such a file or folder, then a request to get its contents, then a request for each file in there, so it could display a size and icon. And the virusscanner requesting those files too, since they were being accessed.
Each operation, in VB.NET, would open and close a connection on my local machine, with a local database-server. The speed was limited by the capabilities of the Dokan-driver, not the speed of the database or opening/closing connections.
A_Griffin wrote: I don't expect a huge (or even noticeable) difference in performance with the size of databases I'm working with at the moment. ..then fill a table with 2 million records. Generate some nonsense-data in a loop and give it a try.
If your boss asks why you choose one or the other, it is better to present an experiment than to point to some idiot on the internet
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I said "NEW"; pooling is not making "new" connections.
I also didn't limit the number of connections from a single client to multiple servers / devices.
I also didn't specify "database servers" (SQL or otherwise); or only "client and (one) server".
TCP/IP is not limited to "databases".
A "new" TCP connection (first or a reconnect) requires hand-shaking not incurred once the connection is "open".
"Databases"? ok .. You get it by default; no thinking there.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Gerry Schmitz wrote: I said "NEW"; pooling is not making "new" connections. Obvious to both of us, but not to the casual reader who just sees "New Connection()".
Gerry Schmitz wrote: I also didn't specify "database servers" (SQL or otherwise); or only "client and (one) server". Would not need to, anything behind the abstraction of the Data Provider is irrelefant.
Gerry Schmitz wrote:
TCP/IP is not limited to "databases". ..I did not imply such.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
How to get each items "valuemember" value of checkedlistbox using for loop and show it in messagebox in winform
|
|
|
|
|
|
I need a OneWire Library to use in vb.net 2017.
a library wich Had emplimented the hole protocol as do Dallas for Ardino .
Thanks to your helps .
|
|
|
|
|