|
Hello,
I am reading values from an Access Database with an OleDbDataReader. I am using the following command:
myCommand.CommandText =
"SELECT FolderName, SecurityGroupName " +
"FROM tblFolderSecurityTemplateInternal";
I am then putting this data into a dynamic array. Here is my problem. I need a way to have the DataReader output to a multi dimensional array. MyReader only takes one value in the array: Ex: subitems1[j,k] = myReader1[j].ToString(); Ultimately, I want to set subitems[j] = to a new variable called FolderNm and subitems[k] = to a new variable called SecurityGroupNm.
OleDbDataReader myReader1;
myReader1 = myCommand.ExecuteReader();
int nFields1 = myReader1.FieldCount;
while (myReader1.Read())
{
// Create an array of subitems
String[] subitems1 = new String[nFields1];
for (int j = 0; j < nFields1; j++)
{
for (int k = 0; k < 2; k++)
{
subitems1[j, k] = myReader1[j].ToString();
}
}
myReader1.Close(); //Close the reader.
|
|
|
|
|
Hello,
I have seen the vb.net sample code on msdn for setting permissions for new folders (below), but still have some questions about it. I am writing a program that creates new folders, and sets permissions for the new folders. An Access database contains the permissions for each group. I have found very little information and examples for this subject. If anyone is familiar with security and the .NET 2.0 framework, I would greatly appreciate the help. Thank you for reading this message!
Imports System
Imports System.IO
Imports System.Security.AccessControl
Module DirectoryExample
Sub Main()
Try
Dim DirectoryName As String = "TestDirectory"
Console.WriteLine("Adding access control entry for " + DirectoryName)
' Add the access control entry to the directory.
AddDirectorySecurity(DirectoryName, "MYDOMAIN\MyAccount", FileSystemRights.ReadData, AccessControlType.Allow)
Console.WriteLine("Removing access control entry from " + DirectoryName)
' Remove the access control entry from the directory.
RemoveDirectorySecurity(DirectoryName, "MYDOMAIN\MyAccount", FileSystemRights.ReadData, AccessControlType.Allow)
Console.WriteLine("Done.")
Catch e As Exception
Console.WriteLine(e)
End Try
Console.ReadLine()
End Sub
' Adds an ACL entry on the specified directory for the specified account.
Sub AddDirectorySecurity(ByVal FileName As String, ByVal Account As String, ByVal Rights As FileSystemRights, ByVal ControlType As AccessControlType)
' Create a new DirectoryInfoobject.
Dim dInfo As New DirectoryInfo(FileName)
' Get a DirectorySecurity object that represents the
' current security settings.
Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl()
' Add the FileSystemAccessRule to the security settings.
dSecurity.AddAccessRule(New FileSystemAccessRule(Account, Rights, ControlType))
' Set the new access settings.
dInfo.SetAccessControl(dSecurity)
End Sub
' Removes an ACL entry on the specified directory for the specified account.
Sub RemoveDirectorySecurity(ByVal FileName As String, ByVal Account As String, ByVal Rights As FileSystemRights, ByVal ControlType As AccessControlType)
' Create a new DirectoryInfo object.
Dim dInfo As New DirectoryInfo(FileName)
' Get a DirectorySecurity object that represents the
' current security settings.
Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl()
' Add the FileSystemAccessRule to the security settings.
dSecurity.RemoveAccessRule(New FileSystemAccessRule(Account, Rights, ControlType))
' Set the new access settings.
dInfo.SetAccessControl(dSecurity)
End Sub
End Module
AR
|
|
|
|