|
i have an application that I wrote about a year ago. Within this application I allow certain users to change the DB access for all users of the application on a given PC.
SaveSetting("DMaTS", "SQL_Server", "ServerName", gstrServer)
**where gstrServer is the name of the server)
This has worked without issue until recently when I have opened this code up and have added new functionality. Now the SaveSettings only works for the user that applied the DB Change. Is this change if bahavior something to do with some security patching?
If I do a registry check for the entry is lists under "Current User..."?
I am a bit puzzled by this change in behavior and am looking for an explanation of why, as well as any corrective action I should take to correct my code and coding habits.
Thanks in Advance.
mtognetti.
|
|
|
|
|
SaveSetting has always saved to HKEY_CURRENT_USER . I don't know what's changed, but this functionality wasn't it. Anything saved under CurrentUser is visible only to the user that saved it, not to anyone else.
If you need to save application settings that apply to all users of your application, then they should have gone under HKEY_LOCAL_MACHINE .
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
As I have done some further reading since posting this I have come to the same conclusion that you have.
Thank you for the validation. I will now redefine this to actually change/add the setting to HK_Local_Machine. This way I will actually get the functionality that I am expecting...all of the time.
Thanks again.
Mtognetti
|
|
|
|
|
Hi everyone,
I have found tons and tons of code on how to add users to the active directory, but I have not found much on how to set folder permission for these users. I have an FTP site that I use a batch to create 50 username and password combinations and then I add those to the active directory (currently by hand; working on code for autonomous). I then have to set all the user permissions to the folder that is reserved for each user. Everywhere I look there is very little discussion on how to do this automatically. Any help is VERY appreciated. Thanks!
Mike
Gaming at the GuildofBlades.com is the only way to really experiece the level 99 Soul-Sucking Sword!
|
|
|
|
|
Here is a sample code I would like to be able to cut in half. The Dim is the only difference. I want to connect to a different db - through web services - based on a command button clicked in Excel. I currently have the button set a property (thanks Dave) in the form but this is a bunch of repeated code (and this is one of the short segments). I would put just the Dim in the If statement but since I can't use it outside of the if the rest of the code has no definition.
Private Sub frmCJ_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dsOrg As DataSet
If m_ConnectionString = "prod" Then
Dim wsrv As New seoweb.Service1
dsOrg = wsrv.CJGetOrganization
Dim DV As DataView = dsOrg.Tables(0).DefaultView
With cbOrganization
.DataSource = DV
.DisplayMember = "organization"
.ValueMember = "organization"
End With
Else
Dim wsrv As New seodev.Service1
dsOrg = wsrv.CJGetOrganization
Dim DV As DataView = dsOrg.Tables(0).DefaultView
With cbOrganization
.DataSource = DV
.DisplayMember = "organization"
.ValueMember = "organization"
End With
End If
End Sub
|
|
|
|
|
Private Sub frmCJ_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
Dim dsOrg As DataSet<br />
<br />
If m_ConnectionString = "prod" Then<br />
Dim wsrv As New seoweb.Service1<br />
dsOrg = wsrv.CJGetOrganization<br />
Else<br />
Dim wsrv As New seodev.Service1<br />
dsOrg = wsrv.CJGetOrganization<br />
End If<br />
<br />
'common stuff<br />
Dim DV As DataView = dsOrg.Tables(0).DefaultView<br />
With cbOrganization<br />
.DataSource = DV<br />
.DisplayMember = "organization"<br />
.ValueMember = "organization"<br />
End With<br />
End Sub
This is what I got out of your code. Simplifies it slighty
|
|
|
|
|
Does anybody know if it is possible to clear the ErrorProvider on ALL controls with one simple function?
ErrorProvider1.SetError([ALL Controls], "")
Thanks
Brad
|
|
|
|
|
No, but you could create your own,
This is what I use:
'--- hErrorProvider.vb -------
Public Class hErrorProvider
Inherits System.Windows.Forms.ErrorProvider
#Region " Component Designer generated code "
Public Sub New(ByVal Container As System.ComponentModel.IContainer)
MyClass.New()
'Required for Windows.Forms Class Composition Designer support
Container.Add(Me)
End Sub
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Component overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Component Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Component Designer
'It can be modified using the Component Designer.
'Do not modify it using the code editor.
<system.diagnostics.debuggerstepthrough()> _
Private Sub InitializeComponent()
components = New System.ComponentModel.Container
End Sub
#End Region
Private _errorList As New ArrayList
Private _activeControl As Control
Public Shadows Sub SetError(ByVal control As Control, ByVal value As String)
If value = "" Then
If _errorList.Contains(control) Then
_errorList.Remove(control)
End If
Else
If Not _errorList.Contains(_errorList) Then
_errorList.Add(control)
End If
End If
MyBase.SetError(control, value)
End Sub
Public Shadows Sub SetError(ByVal value As String)
If _activeControl Is Nothing Then
Throw New Exception("Active control has not been set.")
End If
Call Me.SetError(_activeControl, value)
End Sub
Public Sub ClearError(ByVal control As Control)
If _errorList.Contains(control) Then
_errorList.Remove(control)
End If
MyBase.SetError(control, "")
End Sub
Public Sub ClearError()
If _activeControl Is Nothing Then
Throw New Exception("Active control has not been set.")
End If
Call Me.ClearError(_activeControl)
End Sub
Public Sub ClearAll()
For Each control As Control In _errorList
MyBase.SetError(control, "")
Next
_errorList.Clear()
End Sub
Public Function HasErrors() As Boolean
Return _errorList.Count > 0
End Function
End Class
|
|
|
|
|
Hi folks,
I have a kind of listview, with a couple of 1000 items.
Each item displays a bitmap of around 100x100 pixels.
Because it takes very long to make the bitmap, each item caches the bitmap instead of redrawing it over again.
But, because there are so many items, memory goes berserk (+200000 private bytes)
Each bitmap has a pixelformat of 32bppPArgb.
Because i want to keep the memory within bounds, i would like to change this to Format16bppArgb1555 or something.
But then i can't create a Graphics object from the bitmap (OutOfMemoryException).
Does anyone here have any ideas?
Thanks in andvance!
|
|
|
|
|
... but you guys probably already thought of that
|
|
|
|
|
I want to send data to one of control of parent form from child form at run time . how can I ?
|
|
|
|
|
|
I am calling a stored procedure in my vbscript and I need to be able to grab the results from the stored procedure execution. Right now I have tried several accessors, but nothing seems to be working. Also other methods I have seen done actually return fields from a table, the sql procedure I am executing is printing strings.
Does anyone know how to do this? Or any other thoughts how I could integrate this into my script?
TIA
VB CODE
-----
Dim dbnames_connection_jobs
Dim dbnames_command_jobs
Dim dbnames_recordset_jobs
Set dbnames_connection_jobs = CreateObject("ADODB.Connection")
Set dbnames_command_jobs = CreateObject("ADODB.Command")
Set dbnames_recordset_jobs = CreateObject("ADODB.Recordset")
dbnames_connection_jobs.ConnectionString = "Provider='sqloledb';Data Source='" & database_name & "';" & _
"Initial Catalog='master';Integrated Security='SSPI';"
dbnames_connection_jobs.open
dbnames_command_jobs.ActiveConnection = dbnames_connection_jobs
dbnames_command_jobs.CommandTimeout = 15
dbnames_command_jobs.CommandText = "exec sp_help_revlogin"
Set dbnames_recordset_jobs = dbnames_command_jobs.Execute
----
Stored Procedure
----
CREATE PROCEDURE sp_help_revlogin @login_name sysname = NULL AS
DECLARE @name sysname
DECLARE @xstatus int
DECLARE @binpwd varbinary (256)
DECLARE @txtpwd sysname
DECLARE @tmpstr varchar (256)
DECLARE @SID_varbinary varbinary(85)
DECLARE @SID_string varchar(256)
IF (@login_name IS NULL)
DECLARE login_curs CURSOR FOR
SELECT sid, name, xstatus, password FROM master..sysxlogins
WHERE srvid IS NULL AND name <> 'sa'
ELSE
DECLARE login_curs CURSOR FOR
SELECT sid, name, xstatus, password FROM master..sysxlogins
WHERE srvid IS NULL AND name = @login_name
OPEN login_curs
FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd
IF (@@fetch_status = -1)
BEGIN
PRINT 'No login(s) found.'
CLOSE login_curs
DEALLOCATE login_curs
RETURN -1
END
SET @tmpstr = '/* sp_help_revlogin script '
PRINT @tmpstr
SET @tmpstr = '** Generated '
+ CONVERT (varchar, GETDATE()) + ' on ' + @@SERVERNAME + ' */'
PRINT @tmpstr
PRINT ''
PRINT 'DECLARE @pwd sysname'
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
PRINT ''
SET @tmpstr = '-- Login: ' + @name
PRINT @tmpstr
IF (@xstatus & 4) = 4
BEGIN -- NT authenticated account/group
IF (@xstatus & 1) = 1
BEGIN -- NT login is denied access
SET @tmpstr = 'EXEC master..sp_denylogin ''' + @name + ''''
PRINT @tmpstr
END
ELSE BEGIN -- NT login has access
SET @tmpstr = 'EXEC master..sp_grantlogin ''' + @name + ''''
PRINT @tmpstr
END
END
ELSE BEGIN -- SQL Server authentication
IF (@binpwd IS NOT NULL)
BEGIN -- Non-null password
EXEC sp_hexadecimal @binpwd, @txtpwd OUT
IF (@xstatus & 2048) = 2048
SET @tmpstr = 'SET @pwd = CONVERT (varchar(256), ' + @txtpwd + ')'
ELSE
SET @tmpstr = 'SET @pwd = CONVERT (varbinary(256), ' + @txtpwd + ')'
PRINT @tmpstr
EXEC sp_hexadecimal @SID_varbinary,@SID_string OUT
SET @tmpstr = 'EXEC master..sp_addlogin ''' + @name
+ ''', @pwd, @sid = ' + @SID_string + ', @encryptopt = '
END
ELSE BEGIN
-- Null password
EXEC sp_hexadecimal @SID_varbinary,@SID_string OUT
SET @tmpstr = 'EXEC master..sp_addlogin ''' + @name
+ ''', NULL, @sid = ' + @SID_string + ', @encryptopt = '
END
IF (@xstatus & 2048) = 2048
-- login upgraded from 6.5
SET @tmpstr = @tmpstr + '''skip_encryption_old'''
ELSE
SET @tmpstr = @tmpstr + '''skip_encryption'''
PRINT @tmpstr
END
END
FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd
END
CLOSE login_curs
DEALLOCATE login_curs
RETURN 0
GO
---
|
|
|
|
|
You'd probably have to setup a Parameter object, in your Command object, with a direction parameter of adParamReturnValue . You could probably read the results from that parameter after the Execute method returns.
Or you might be looking for something like this[^] example.
I don't know for sure which one will work for you. I never had to look at the return value text before...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Made some small changes to the variable names, but tried what was posted in:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdconcommandparams.asp
and here
http://www.microsoft.com/resources/documentation/Windows/2000/server/reskit/en-us/iisbook/c07_returning_values_from_stored_procedures.asp
Now getting error' Item cannot be found in the collection corresponding to the requested name or ordinal.
800A0CC1
This means that the Recordset var isn't getting any data returned to it, but the stored proc when run in query analyzer is returning data?
What do I have blatantly incorrect in the code below?
--
Dim userinformation_connection_jobs
Dim userinformation_command_jobs
Dim userinformation_recordset_jobs
Set userinformation_connection_jobs = CreateObject("ADODB.Connection")
Set userinformation_command_jobs = CreateObject("ADODB.Command")
Set userinformation_recordset_jobs = CreateObject("ADODB.Recordset")
userinformation_connection_jobs.ConnectionString = "Provider='sqloledb';Data Source='" & database_name & "';" & _
"Initial Catalog='master';Integrated Security='SSPI';"
userinformation_connection_jobs.open
userinformation_command_jobs.ActiveConnection = userinformation_connection_jobs
userinformation_command_jobs.CommandTimeout = 15
userinformation_command_jobs.CommandText = "exec sp_help_revlogin"
'userinformation_command_jobs.CommandType = adCmdStoredProc
Set userinformation_recordset_jobs = userinformation_command_jobs.Execute
userinformation_recordset_jobs(0).Direction = adParamReturnValue
'userinformation_command_jobs.Execute
output_file.WriteLine(userinformation_recordset_jobs(0))
|
|
|
|
|
The winform project could not be build and run.
How to change the code.
Such as
My.Application
Shundown
Auther..
|
|
|
|
|
That's the price of using a beta.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
The changes are too many to list. If your using the My stuff, then your basically going to create a new Windows Forms application and recreate your forms, then copy/paste some of your code, correct anything that was changed between beta's, ...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi
I am Ilangovan newbie for .NET programming.I have to Get windows XP login & logout time using VB.NET or ASP.NET or C#.....can anyone help me pls?
Thanks in advance
M.Ilangovan
|
|
|
|
|
Since this information isn't stored anywhere, you'll have to write a Windows Forms application that is run from the All Users/Startup Folder or from the Run registry key.
This application would just record the time when it starts, meaning a user logged in, the username, and when Windows quits, the current time when the application is told to shutdown.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Here is another way to get at the logs in VB.Net:
HOW TO: Manage Event Logs by Using Microsoft Visual Basic .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;814564[^]
You can parse the times with:
Dim CurrentEntry As EventLogEntry = ev.Entries(i)
Console.WriteLine("Event Time : " & CurrentEntry.TimeGenerated)
|
|
|
|
|
Are there any ways to bind information from a XML file into a listbox for Vb.Net?
e.g I need to display all the products that are in the XML file into the listbox for the user to choose from.
Another question would be how do we edit XML files?
e.g After creating a XML file, I need to add more products into the XML file
my project is mainly about product inventory
|
|
|
|
|
Nguyen Dinh Quy wrote:
e.g I need to display all the products that are in the XML file into the listbox for the user to choose from.
I'm not sure if there is an easier way, but I tend to get a node collection with an XPath, then I build an arraylist of strings from that and bind that to the listbox.
Nguyen Dinh Quy wrote:
After creating a XML file, I need to add more products into the XML file
If you load your XML file into an XmlDocument, this class has methods to create new nodes, which you can then modify and insert nto the document by finding the parent node and calling (from memory) appendchild. It's involved enough that I wrote a wrapper for it all for wdwj mag a few years ago, but in hindsight I don't use it, it's not that bad.
Nguyen Dinh Quy wrote:
my project is mainly about product inventory
Don't you think a SQL database is a better choice than XML ? How will you do searches ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Do MSMQ really copy objects (like text files) into queue or do they only copy the content of that object?
|
|
|
|