Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Location
    Oxfordshire, UK
    Posts
    89

    Question Unanswered: ADODB/ADOX Workspace equivalent?

    Hi There,

    I'd like to ask y'all about another conversion problem. I'm working with a File Server Access 2000 app - one file contains the data and the other the forms, reports, modules etc (front-end file). The front-end file has linked tables which reference the data file.

    Now, both files are secured using the same Workgroup Information File and DAO allows me to reference the data file from code in the front end file without resubmitting mdw file, user name, or password information like this:

    Dim wspCurrent as DAO.Workspace
    Dim dbCurrent as DAO.Database

    Set wspCurrent = DBEngine.Workspaces(0)
    Set dbCurrent = wspCurrent.OpenDatabase("Data FilePath")

    This is very useful for manipulating Data File objects.

    I've tried do this in ADODB/ADOX without much success. Anybody got any ideas?

    Ta


    Ian

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    From Help:

    Code:
    Dim cnn1 As ADODB.Connection
    	Dim rstEmployees As ADODB.Recordset
    	Dim strCnn As String
    	Dim varDate As Variant
    
    	' Open connection.
    		strCnn = "Provider=sqloledb;" & _
    		"Data Source=srv;Initial Catalog=Pubs;User Id=sa;Password=; "
    	Set cnn1 = New ADODB.Connection
    	cnn1.Open strCnn
    	
    	' Open employee table.
    	Set rstEmployees = New ADODB.Recordset
    	rstEmployees.CursorType = adOpenKeyset
    	rstEmployees.LockType = adLockOptimistic
    	rstEmployees.Open "employee", cnn1, , , adCmdTable
    
    	' Assign the first employee record's hire date
    	' to a variable, then change the hire date.
    	varDate = rstEmployees!hire_date
    	Debug.Print "Original data"
    	Debug.Print "  Name - Hire Date"
    	Debug.Print "  " & rstEmployees!fName & " " & _
    		rstEmployees!lName & " - " & rstEmployees!hire_date
    	rstEmployees!hire_date = #1/1/1900#
    	rstEmployees.Update
    	Debug.Print "Changed data"
    	Debug.Print "  Name - Hire Date"
    	Debug.Print "  " & rstEmployees!fName & " " & _
    		rstEmployees!lName & " - " & rstEmployees!hire_date
    
    	' Requery Recordset and reset the hire date.
    	rstEmployees.Requery
    	rstEmployees!hire_date = varDate
    	rstEmployees.Update
    	Debug.Print "Data after reset"
    	Debug.Print "  Name - Hire Date"
    	Debug.Print "  " & rstEmployees!fName & " " & _
    		rstEmployees!lName & " - " & rstEmployees!hire_date
    
    	rstEmployees.Close
    	cnn1.Close


    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •