I am attempting to learn how to develop applications to interact with the Autonomy WorkSite 8.5 server and have found the WorkSite DB Administrators COM Developers Reference Guide, it has helped me somewhat and I can now see the types of objects that I can interface with however, I am stumbling on showing the members of a group.
My code is as follows. This is for a VB.NET Windows Forms application.
Dim ObjNRDMS As IMANADMIN.NRTDMS
Dim ObjSessions As IMANADMIN.NRTSessions
Dim ObjSession As IMANADMIN.NRTSession
Dim ServerName As String
ServerName = "SERVERNAME"
' Create the NRTDMS object
ObjNRDMS = GetObject("IMANADMIN.NRTDMS")
' Add the Server to the NRTSessions object and
' get a NRTSession object for the server
ObjSessions = ObjNRDMS.Sessions
ObjSessions.Add(ServerName)
ObjSession = ObjSessions.Item(1)
' Login to the Server
ObjSession.TrustedLogin()
Dim ObjDBs As IMANADMIN.NRTDatabases
Dim ObjDB As IMANADMIN.NRTDatabase
Dim ObjGroup As IMANADMIN.NRTGroup
' ObjSession is a previously defined NRTSession object
' Get the first database defined for ObjSession object
ObjDBs = ObjSession.Databases
ObjDB = ObjDBs.Item(1)
ObjGroup = ObjDB.GetGroup("TEST")
txtOutput.AppendText(ObjGroup.Users.ToString)
However, when I debug this code in Visual Studio (2008), I get the error:
Cannot create ActiveX component at the line `ObjNRDMS =
GetObject("IMANADMIN.NRTDMS")
I have run regsvr32 iManAdmin.dll.
Can anyone offer any assistance on this problem?
I've read on page 21 of the DB Admin COM guide that it mentions to execute iManAdmin - REGSERVER from the command prompt, however this will not work for me with Windows reporting that the file does not have a open with program set.
I ended up resolving this issue by using the iManage worksite Interop.iManAdmin.dll
Related
I am able to connect Python to my Oracle SQL DB on a Windows computer, but strangely enough I cannot seem to get it working from VBA.
For reference, this is the Python Code to connect:
cx_Oracle.connect(f'{self.user}/{self.pwd}#//{self.host}:{self.port}/{self.service_name}')
I have tried replicating this similar structure in my VBA code, but I get an error message. Here is the code I've been using:
Sub CallDB_Return_Flexible(stSQL As String, rstStart As Range)
Dim sqlConn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim rtn As Boolean
Dim cmd As New ADODB.Command
Dim cs As String
'On Error Resume Next
Set sqlConn = New ADODB.Connection
cs = "Provider=OraOLEDB.Oracle;User ID=myuserID;Password=myPsswd;Data Source=host:port/service_name;"
sqlConn.ConnectionString = cs
sqlConn.CommandTimeout = 10000
sqlConn.Open
I get the following error messages:
1) The system cannot find message text for message text 0x80040e0c in the message file for OraOLEDB.
2) Sometimes, dependent on the iteration of the connection I use (IE a TNS connection), I get a TNS listener error message.
I currently have the ActiveX 6.1 Data Objects Library enabled. Furthermore, I am on a 64-bit machine with a 64-bit Oracle client installed. I have a 64-bit Office. I am quite certain I have a 64-bit ADO as well - my ODAC (if this is the same) is the same as the 64 bit version online. I have an ODP.NET of 2.12 and another with 4.121 in the registry. I just have an ODP.NET.Managed of 4.12.
This doesn't make much sense to me, how in one language I can connect with no issues, but in another I cannot!
I backtested using an earlier ActiveX Data Library - this solved it.
Thank you!!!!!
Well this is fascinating. I am using MS-Access 2007 to make a from that will allow users to enter data from lab results.
The from utilizes a VBA code call:
DAO.OpenRecordset("{Sql query}" , DB_OPEN_DYNASET, dbSeeChanges)
This call normally works just fine, but I've noticed that when this form is closed and then re-opened, a 3151 ODBC error is generated.
We are using linked tables through Access 2007 for this form, our SQL-Server 2012 version is as follows.
Microsoft SQL Server Management Studio 11.0.2100.60
Microsoft Analysis Services Client Tools 11.0.2100.60
Microsoft Data Access Components (MDAC) 6.1.7601.17514
Microsoft MSXML 3.0 6.0
Microsoft Internet Explorer 8.0.7601.17514
Microsoft .NET Framework 4.0.30319.237
Operating System 6.1.7601
The DAO.OpenRecordset call is utilized in multiple events. Here is the list.
On_Current , _AfterUpdate , Form_Unload
I have found several reported instances of similar errors on Access 2007 with linked tables to SQL-Server, but none seem to have workable solutions for this issue.
As best I can tell, the 3151 doesn't appear to be affecting the form or data in any negative way. I am able to open the form and everything is where it should be as best I can tell. There are about 20 thousand records on this table, so I may be missing something.
Does anyone have any ideas?
9/14 In response to comments I am adding some additional code.
Here is the call on Form_Unload. It contains the failing line.
Private Sub Form_Unload(Cancel As Integer)
Dim ImportID
Dim rst As DAO.Recordset
Dim db As Database
Set db = CurrentDb
Set ImportID = Me.ImportID
#This is the failing line below.
Set rst = db.OpenRecordset("SELECT [dbo_t_inspect].* FROM [dbo_t_inspect] WHERE [dbo_t_inspect].ImportID= " & ImportID & ";", DB_OPEN_DYNASET, dbSeeChanges)
Here is the call from On_Current. This On_Current call is actually made by a sub-form on the main form.
Private Sub Form_Current()
Dim rst As DAO.Recordset
Dim strImportID As String
If IsNull(Me.ImportID) Then
[Forms]![Inspection Receiving]![LabComplete].Visible = False
[Forms]![Inspection Receiving]![LabPending].Visible = True
Else
strImportID = Me.ImportID
Dim db As Database
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT [dbo_t_health].*, [dbo_t_health].ImportID FROM [dbo_t_health] WHERE ((([dbo_t_health].ImportID)=" & Me.ImportID & "));", DB_OPEN_DYNASET, dbSeeChanges)
I am not sure where DAO is defined in this solution. I cannot find it's declaration in my folder titled Microsoft Office Access Class Objects I am open to suggestions on where that might be located.
The precise error message is as follows
Failed to connect to {ODBC Connection Name} Error 3151.
I can then select the debug option and the debugger will take me to the line that tried and failed to connect the the ODBC Connection I am using.
The Error is highly reproducible. All I have to do is enable VBA Macros on the Security Alert and then open the form in question. I close out the form after it loads. Once I attempt to reopen the form, I get the error described above. The Form opens anyway after I click Ok on the error.
I am developing a VB.NET update system for a volunteer organisation’s MS Access database. The database is protected by a password as it contains personal information. I have created the application using the VB designer. I need to be able to code the application so that, if the owner decides to change the MS Access password, they will have no need to come back to me to change the code and rebuild the solution. In other words, I do not want the password to be hard coded in the app.config file or the settings.designer.vb file. My code should not need to know the password as a simple call to one of the Fill functions can test any password entered by the user. My problem is that I have found no way to alter the connection string that is tested in the setttings.designer.vb code whenever the database is accessed. I am using Visual Studio 2017.
I have spent a long time searching the web for answers and have tried various solutions involving the configurationmanager without success. I am new to this area so I would be most grateful if anyone here can help.
Here is my latest attempt which still produces an invalid password error even though the third debug statement suggests that the connection string, including the password, has been correctly set.
Public Sub UpdateConnString(connString As String)
Dim configFileMap As New ExeConfigurationFileMap()
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(configFileMap.ExeConfigFilename)
Dim connStringName As String = "TestConnectionString"
Debug.Print("0 " + config.ConnectionStrings.ConnectionStrings(connStringName).ConnectionString)
config.ConnectionStrings.ConnectionStrings(connStringName).ConnectionString = connString
Debug.Print("1 " + config.ConnectionStrings.ConnectionStrings(connStringName).ConnectionString)
config.Save(ConfigurationSaveMode.Modified, True)
Debug.Print("2 " + config.ConnectionStrings.ConnectionStrings(connStringName).ConnectionString)
End Sub
Just because a connection string is stored in the config file, you aren't required to use it as it is. You can read in that default value and then edit it before using it, e.g.
Dim builder As New OleDbConnectionStringBuilder(My.Settings.DefaultConnectionString)
builder.DataSource = dataSource
Dim connectionString = builder.ConnectionString
You can add or modify any part of a connection string you want that way at run time.
Thank you for your response. Unfortunately, the code throws a compilation error - "DefaultConnectionString is not a member of My.Settings".
Fortunatley I have now managed to find a working solution:
'My.Settings.Item("TestConnectionString") = connectionString
I have the following function in an Excel sheet module, which sends SQL queries to SAS:
Function run_query(query)
Dim app ' application
Dim project ' Project object
Dim sasProgram ' Code object (SAS program)
Set app = CreateObject("SASEGObjectModel.Application.5.1")
Set project = app.New
Set sasProgram = project.CodeCollection.Add
sasProgram.Text = "PROC SQL;" + query + " QUIT;"
sasProgram.Run
app.Quit
End Function
It sometimes works like a charm, and most often doesn't, as it asks for my credentials (triggered by command sasProgram.Run as it's where the debugger stops), I didn't find a way to make the error, or success, reproducible.
I've set my credentials persistence to Persist for user but I still have issues.
I've also tried to set my Autentification to None (attempt anonymous connection) and Windows integrated (Uses your current windows account) and none of them changed the situation.
I'm trying to run a macro from ms access 2010 from vb.net 2010 ..
The code I used is
Dim oAccess As Access.ApplicationClass
'Start Access and open the database.
oAccess = CreateObject("Access.Application")
oAccess.Visible = True
oAccess.OpenCurrentDatabase("C:\Users\Yuganshu\Desktop\New folder (4)\WindowsApplication1\db.mdb", False)
'Run the macros.
oAccess.Run("Macro1")
'oAccess.Run("DoKbTestWithParameter", "Hello from VB .NET Client")
'Clean-up: Quit Access without saving changes to the database.
oAccess.DoCmd().Quit(Access.AcQuitOption.acQuitSaveNone)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oAccess)
oAccess = Nothing
This is giving me following error:
Unable to cast COM object of type 'Microsoft.Office.Interop.Access.ApplicationClass' to class type 'WindowsApplication1.Access.ApplicationClass'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.
I don't know what to do.
You need to add the correct COM Reference. Click the Project Menu bar then-->Add reference. Under Type Libraries look for Microsoft Access 14.0 or whatever version your machine is running. Then add the following statements.
Imports Microsoft.Office.Interop
Dim Access_Object As New Access.Application
Access_Object = CreateObject("Access.Application")
Access_Object.Application.Visible = True