Do I need to use ADO when connecting to Active Directory with VBA? - vba

I need to query Active Directory and build my MS Access database using the results. I found some code here. As you can see, part of this code is creating an ADODB.Connection object. Is this the only method for connecting to AD? Is it possible to use DAO objects?
I've never taken any courses on databases so forgive me if this question makes no sense.
Thanks!

As you can see part of this code is creating an ADODB.connection object. Is this the only method for connecting to AD? Is it possible to use DAO objects?
Personally I wouldn't recommend trying to use DAO to query AD. DAO works very well to manipulate Access database tables from within Access itself, but for Access VBA code to manipulate any data source that isn't...
a local Access table or
an Access "linked table"
...I would recommend using ADO. You can use the code samples in the article you cited, and if you run into any difficulties you will be much more likely to receive meaningful assistance.

Related

Create a Jet Database Only using VB.Net

I want to Create a Database that i can publish with a VB.Net Program. I did it just fine Linking MS Access but the problem is what if the user doesn't have Access. So i asked around a bit and one of my teachers said to use a jet database.
Is there a better option for sending a database that the user needs to populate when i publish?
if not!
How can i create a Jet database only in VB.net?
Using this option I will of course need to send 2 programs along one to Populate the data and one to Read and do its job.
Any help would be much appreciated thank you!
If it's a fairly simple database that you are going to be using then you might also want to take a look at sql compact edition. I won't say that this is superior to jet databases but you might find distribution easier.

accessing Access 2007 System Object tables and schemas

I am looking for some help on retrieving Access 2007 database schema information for system object tables. I have reviewed, read and tested this successfully for the non system tables. The database tables info I am trying to retrieve are in the tables that begin with MSys{xxxxxxxxxx} and store things like relationships, creation date, dateupdate, etc. This tables are viewable by right clicking on the Navigation Options popup menu in Access and selecting Show System Objects.
For clarification, I have added the System.mdw database to the connection string, and I have attempted multiple settings in the restrictions property of the getSchema method. I am using ado.net, vb.net, and VS2008, these are access 2007 databases not mdb files.
My issue appears to continue to be no read access to the System tables. My end goal is to manage relationships initially and eventually hopefully script these databases much like can be done EASILY (Microsoft) in SQL Server Mgmt Studio.
I am hoping someone can point me to some good web link resources or even a good book that clearly discusses this functionality.
thanks,
As it turns out the easiest way to gain access to the system table data is to execute a permissions command on the Systems database table(s). The following query did the trick....
Dim strDdl As String = "GRANT SELECT ON MSysObjects TO Admin;"
Dim command12 As New OleDbCommand(strDdl, connection)

Updating Datatable to EXISTING global database connection

I am using Microsoft Visual Basic 2010 Express. I have a WPF-based project. I have a successful connection to a database in Database Explorer, and a working existing Data Source in Data Sources.
I created a datatable from the datasource using this code:
Dim roster_table As New DataTable("AGENT_ROSTER")
I can manipulate this datatable just fine, but I cannot figure out how to save its data to my database (agentroster.sdf) since the connection is on a global level, and isn't declared in this particular window.
How do I update this database from the datatable on this window?
By the way, I tried creating a connection on this window's code, using the exact same connection string as the successful globally-connected database, yet it said that it couldn't connect.
Tough to say given the limited information you provided. You should also note that there are a lot of ways to do this. However the most basic way is to use a table adapter. Once you've set the Update, Insert and Delete commands you call its Update method.
Here's an MSDN article that might help you further

Create Access databases programatically through vb.net

Let me preface this by saying that I know this is a stupid way to go about this, but it needs to be handled in this way.
I need to make an application that from a master database creates a number of access database files (tables of a larger db), then these are manually given to users who fill in data, the database files are emailed back to a user who, through the application, combines them again.
The only part of this that I am unsure about is problematically creating the access db's. I have read that through Microsoft Jet OLE DB Provider and Microsoft ADO Ext I can create them (the tables and data), but I also need forms.
I have yet to start writing anything and this is away from my area of work, so any insight/links would be much appreciated.
Also, I would hope to be able to write this in the free express version of visual studio. Are there components needed that would prevent me from this? Thanks.
If you are developing in vb.net then why do you need forms in the Access database? Create a vb.net application for the "client" pcs with the required forms reading and writing to the Access database.
If however you do need to have forms in an Access database. Create a database with the required forms and code. Distribute the code/form database and the data database. Add a method to the code/form database the creates links to the tables in the "data" database.

Creating Simple desktop database application

I am here to write a small database application that will be running in desktop (offline mode).
I am using MSAccess 2007 as my database file and trying to write code in vb.net.
I used to write the code vb6 an usually had global variables for storing database connection and executing every query from that.
I am trying to upgrade myself from vb6 to vb.net.
do i need to read some more simple starter books also?
In .NET, talking to a database is handled with ADO.NET, which uses something called "connection pooling". The connection pool is basically a collection of open connections to your database that ADO.NET manages for you. In your code, when you create and open a Connection object, ADO.NET first looks in the connection pool to see if it already has an open connection to your data source, and if it finds one it uses that (instead of actually creating and opening a new connection). When you close your connection, ADO.NET does not really close it, but instead returns it to the connection pool.
Therefore, you do not need (and in face do not want) to maintain open connection objects inside your application (in a global variable or anywhere). The correct approach with data access in ADO.NET is to create and Open a Connection object, do whatever you need to do with the database, and then Close and Dispose your Connection.
Store the connection string in the config file (in the solution explorer, open the My Project folder and doubleclick on Settings.settings).
I'd suggest that you create one or more classes to contain your database code and let those classes convert between the database data and your application objects, most VB6 projects I saw had the GUI hard linked to the DB which can make future maintenance or new features very difficult and limits the possiblity of code reuse.
If you've got VB6 experience I'd thought that you could probably start trying to create the application right away but you should definitely read either a good book or good articles about it at the same time so that you pick up things like that you need to Dispose of your database objects after user etc.
It's probably a good idea to get a book, a lot has changed since VB6.
Also consider using a more robust db, like SQL compact or SQLite. It will allow you you use the Entity Framework which will make writing your app a whole lot easier.