I'm trying to fetch data from OID(oracle internet dictionary) LDAP using Excel. Below is the code i have wrote but still its not fetching the data.
Public Function RegUsers()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim isLDAPUserFound As Boolean
Dim str_UserId As String
Try
conn = New ADODB.Connection
conn.Provider = "ADSDSOObject"
conn.Open
isLDAPUserFound = False
str_UserId = "abc123"
If isLDAPUserFound = False Then
rs = conn.Execute("<LDAP://url:port/o=xyzx>;" & "(uid=" & str_UserId & ");uid,mail,CN;subtree")
If Not rs.BOF Then
isLDAPUserFound = True
MsgBox("Something Fonund")
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
Please help me sort this problem.
Note : I have doubt about provider name and should we give system account which is having LDAP admin privileges if yes where should we mention.
Related
I am trying to connect to Oracle DB for the first time using the ODBC Datasource Connector(named Demo_DSN) When I Step Into (F8) the code is giving Run-time error '3706': application-defined or object -defined error
Sub ConnectToOracle()
Dim cn As ADODB.Connection
Dim rs As ADODB.RecordSet
Dim mtxdata As Variant
Set cn = New ADODB.Connnection
Set rs = New ADODB.Recordset
cn.Open ( _
"User ID = XXGMDMADM" & _
";Password=xxgmdmadmdb" & _
";Data Source= Demo_DSN" &_
";Provider= OraOLEDB.Oracle")
'Cleanup in the end
Set rs = Nothing
Set cn = Nothing
End Sub
When i check the result set. record count it returns -1 and while checking the recordset.EOF it returns true, thus the result set does not contain any value.
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL
Private Sub cmd_login_Click()
Dim pass As String
con.ConnectionString = "Provider=msdaora;Data Source=localhost;User Id=ams;Password=krishnan;"
con.Open
strSQL = "Select passwrd from ams.login_details where username = 'Admin'"
rs.Open strSQL, con
If Not (rs.EOF) Then
If rs("passwrd") = txt_pass.Text Then
MsgBox rs("passwrd")
End If
End If
rs.Close
con.Close
End Sub
I forget to commit the statements in Oracle Sql Developer that's why not data was fetched from the database, When i executed the commit statement, it's working fine.
I am developing winform application in vb6. I am using crystal report 4.6. I have created a crystal report which shows all data from a table (MS Access). And I unchecked save data with report and i saved the report. I just want to invoke it in application. So I included the component CrystalReportControl in my application. Now i want to set the records to be displayed in the report. The records are selected according to the user input to the text box.
Records are retrived from the database is done in following code.
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Command1_Click()
Set conn = New ADODB.Connection
conn.Open "provider=Microsoft.jet.oledb.4.0;Data Source=" & App.Path &"\faculty.mdb"
Set rs = New ADODB.Recordset
rs.Open "select * from facultydetails where eid=1234", conn, adOpenDynamic, adLockPessimistic
CrystalReport1.ReportFileName = App.Path & "\faculty.rpt"
Set CrystalReport1.DataSource = rs
CrystalReport1.Action = 1
End Sub
Gives an error for the line: Set CrystalReport1.DataSource = rs :
as Property is write-only.
Tell me how the records of the report can be dynamic? Plz help me...
Instead of
Set CrystalReport1.DataSource = rs
do
CrystalReport1.DataSource = rs
EDIT:
Take a look at the following example and see if that will help you:
'CrystalReport1 is the name of the dsr file
Dim Report As New CrystalReport1
Dim cdoRowset As CrystalDataObject.CrystalComObject
Dim varArray() As Variant
'Open ADO Connection
Set m_cnAdo = New ADODB.Connection
m_cnAdo.ConnectionString = "DRIVER={SQL Server};UID=[UserID];PWD=[Password]" _
& ";SERVER=[Server];DATABASE=[Database]"
m_cnAdo.Open
Dim rsAdo As ADODB.Recordset
Dim cmdAdo As ADODB.Command
'Using Embedded Query
Set cmdAdo = New ADODB.Command
Set rsAdo = New ADODB.Recordset
cmdAdo.ActiveConnection = m_cnAdo
cmdAdo.CommandText = "SELECT * FROM Table WHERE Param = " & lngParam1
cmdAdo.CommandType = adCmdText
Set rsAdo = cmdAdo.Execute
Report.Database.SetDataSource rsAdo, 3, 1
I have the following code. The intent is to have this utility class that I use to hold all my database work and just return populated ADODB.RecordSet objects. I am getting errors. What am I doing wrong?
Public Property Get RecordSetCustomers() As ADODB.Recordset
m_myDB.BuildConfig
Dim cmd As New ADODB.Command
Dim strSQL As String
strSQL = "SELECT * FROM vw_customers"
cmd.CommandType = ADODB.CommandTypeEnum.adCmdText
cmd.ActiveConnection = m_myDB.DbConnection
cmd.CommandText = strSQL
Dim rs As New ADODB.Recordset
Set rs = New ADODB.Recordset
Set rs = cmd.Execute
RecordSetCustomers = rs
End Property
The m_myDB is an object/class that holds all my database configuration/connection params.
The error I am receiving is: 'Compile Error: Invalid use of property'
I tried converting this to a function with same result.
VBA syntax requires the keyword 'set' for object reference assignments. See http://roymacleanvba.wordpress.com/2009/05/08/set-keyword/
...
Set RecordSetCustomers = rs
End property
I started a thread here, this is a continuation from that post: Calling a Module and a Class within a Form
I can't find the information I need to successfully query our database. What I need to do is to get a single value from a Pervasive database. I cannot find the list of ODBC commands to do this with.
Can someone please point me to some documentation that deals with these Pervasive ODBC commands? I'm using ADO ODBC for the connection.
EDIT:
I am also attempt to connect to a MySQL database as well and am hitting the same error. Here is a test Sub I created to call my MySQL function. The error is the same for MySQL as it is for Pervasive: "Object variable or With Block variable not set"
Public Sub testMe(id)
Dim MySqlConn As adodb.Connection 'Do I need this here or in the MySQL function?
Set MySqlConn = ConnectMySQL()
MySqlConn.Open "SELECT * FROM test", MySqlConn, adOpenDynamic, adLockOptimistic
End Function
First, you need to connect to the database. According to this website the connection string would be in this format:
Driver={Pervasive ODBC Client
Interface};ServerName=myServerAddress;dbq=#dbname;
Starting with code from your previous post, it could be extended like this:
Option Explicit
Public Function getEmployee() As String
Dim MyConnection As ADODB.Connection
Dim CM As ADODB.Command
Dim RS As ADODB.Recordset
Set MyConnection = ConnectSQL()
'one way using command objects
Set CM = New ADODB.Command
Set CM.ActiveConnection = MyConnection
CM.CommandType = adCmdText
CM.CommandText = "select * from <table>"
Set RS = New ADODB.Recordset
RS.Open CM, , adOpenStatic, adLockBatchOptimistic
'another way using just the connection
Set RS = MyConnection.Execute("select * from <table>")
'return the data
getEmployee = RS.Fields(0).Value
End Function
Public Function ConnectSQL() As ADODB.Connection
Set ConnectSQL = New ADODB.Connection
ConnectSQL.Open "Driver={MySQL ODBC Client Interface};ServerName=localhost;dbq=#testdb"
End Function