Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 22nd, 2009, 08:12 PM
Authorized User
 
Join Date: Feb 2005
Posts: 47
Thanks: 2
Thanked 0 Times in 0 Posts
Default Using ADOX.Catalog with JScript

Hi all,

I am trying to do the following with JScript. I want to be able to utilize the workgroup file in an access db. I know you have to utilize the ADOX.Catalog and then set the connection string to the workgroup file and the database that the workgroup file is attached. I this is client side code and the database is on a network share that everyone has mapped so that is not an issue. Any ideas on the code??

Here is a sample of the code I have:
Code:
Sub addUser()
            
            Dim adoCat As ADOX.Catalog
            Dim usrNew As ADOX.User
    
            Set adoCat = New ADOX.Catalog
 
            adoCat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
                                                    "Data Provider='Z:/Sample.mdb';" & _
                                                    "jet oledb:system database='Z:/Sample.mdw'"
 
            With adoCat
 
                    .Groups.Append "Something"
                    Set usrNew = New ADOX.User
                    usrNew.Name = "someone"
                    usrNew.ChangePassword "", "Password1"
                    .Users.Append usrNew
                    .usrNew.Groups.Append "Something"
 
            End With
            Set adoCat.ActiveConnection = Nothing
            Set adoCat = Nothing
            Set usrNew = Nothing
            
End Sub
I know the following is VBScript. However when I try to run this code from the click of a button on a web form I get the error that a semi colon is expected on line 2 character 5. If anyone wants I can post the JScript that I have been playing around with and am getting the same error. Any help would be greatly appreciated.

Thanks Chris
 
Old April 22nd, 2009, 11:46 PM
Authorized User
 
Join Date: Feb 2005
Posts: 47
Thanks: 2
Thanked 0 Times in 0 Posts
Default Here is the sample JScript

Hi all,

Okay I did this up in JScript but still no joy. I don't get any errors but it isn't adding a user to the database or the group.

Here is the code.
Code:
function function addUser()
{
 var adoConn = new ActiveXObject("ADODB.Connection");
 var adoCtlg = new ActiveXObject("ADOX.Catalog");
 var adoConnString = "DSN=Sample.dsn";
 
 var newUser = new ActiveXObject("ADOX.User");
 var newGroup = new ActiveXObject("ADOX.Group");
 
 adoConn.Open(adoConnString);
 adoCtlg.ActiveConnection(adoConnString);
 
 adoCtlg.Groups.Append = "Something";
 newUser.Name = "someone";
 newUser.ChangePassword = "","Password";
 .Users.Append newUser
 .newUser.Groups.Append "Something";
}
The DSN is a system DSN and I confirmed it is pointing to the right database and system database. There is no password set for the access database so that shouldn't be an issue. Any thoughts?

Thanks Chris
 
Old April 23rd, 2009, 12:21 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Your connection string won't work as given.

"Data Provider='Z:/Sample.mdb';" &

(1) Even thought Z: might be mapped to a specific drive on YOUR MACHINE using YOUR ACCOUNT, it is unlikely that *ALL* users on your LAN will be using the same mapping.
(2) If this is for server-side JScript (that is, ASP code), you would *still* not be able to use Z: if the mapping for Z: is for YOUR account. Remember, ASP runs under the "IUSR_xxx" account (where "xxx" is the name of the machine it is running on).

You need to give the full UNC path to the directory and DB, *NOT* a drive specification-based path.





Similar Threads
Thread Thread Starter Forum Replies Last Post
catalog scheduling riketa.garg SQL Language 0 April 8th, 2008 12:56 AM
Appending a Table to a Catalog using ADOX ShoeBucket Access VBA 3 June 15th, 2007 01:58 PM
ADOX speedlearner BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 June 23rd, 2006 04:15 PM
ADOX problem toshesh VB Databases Basics 1 December 23rd, 2005 10:34 AM
I can't use ADOX.Catalog to get views or users. yangfanatp2p VB Databases Basics 11 December 12th, 2003 12:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.