Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB 6 RETRIEVING DATA FROM LOTUS NOTES DATABASE

Status
Not open for further replies.

mmt4331

Programmer
Dec 18, 2000
125
US

I have two questions:

1) Can one access data using VB6 from a Lotus Notes
Database?

2) If so, I'm trying to dump employee names into a List
Box, but I get an error message saying that Record Set
set is not found. I set my ODBC w/ the correct server
address and file name (file name is CSG\SystemInfo.NSF).
The record name is also correct....maybe someone can
help me. Here is the code:

Private Sub Command1_Click()

Dim adoConnection As ADODB.Connection
Dim adoRecordset As ADODB.Recordset
Dim connectString As String

Set adoConnection = New ADODB.Connection

Set ado Recordset = New ADODB.Recordset

ConnectString = “ODBC;DatasetName = SystemInfo;”

AdoRecordset.Open “CSG\SYSTEMINFO.NSF”, adoConnection

Do Until adoRecordset.EOF

List1.AddItem adoRecordset!AssociateName

AdoRecordset.MoveNext

Loop

AdoRecordset.Close
AdoConnection.Close
Set adoRecordset = Nothing
Set adoConnection = Nothing

End Sub


 
Hi,

There are several ways to connect to a Notes-database. Here's what I do:
1. Define a Data Source Name (DSN) which connects to the Notes database.
2. Open a connection to the DSN.
3. Define a SQL statement which retrieves data from a table or view in the Notes database.
4. Open the recordset.
5. Access the data by reading the recordset or store all the data in an array (far better performance).

It looks like this:

Dim szSQL As String
Dim sPwd As String
dim sDSN as string
dim sView as string
Dim sStatus As String
Dim sConnection As String
Dim varArray As Variant

Set conn = CreateObject("ADODB.Connection")
sConnection = "DSN=" & sDSN & ";" & "UID=" & gUserID & ";" & "PWD=" & sPwd

conn.Open sConnection
'find out the name of the view or table in the Notes
'database
szSQL = "Select * from " & sView
Set rs = New ADODB.Recordset
rs.CursorType = adOpenForwardOnly 'to maximize performance

'open connection for input
rs.Open szSQL, conn, , , adCmdText

'store data in array in one operation
varArray = rs.GetRows(adGetRowsRest)

rs.Close
 
There are a couple of other methods you could try:

If you know that the user's machine has the Notes client installed, you can access that through COM from your VB app, but you'll need to work your way around the Notes object model.

Alternatively, you could use http to access the data from the notes server, but you will probably need to set up your own views in Notes to get the relevant data.

Nick

PS
I think that you will need NotesSQL for the previous suggestion - I think it is downloadable from
 
Hey guys,

Thanks for your input. Herman, I tried your code (I did rearrange the connection string a little bit. Data still won't load into the list box, because it's asking me for a password. I tried to put in the connection string the password I wanted, but it won't take. I think I'll have to talk to the Lotus team at my place of work (administrator for example) and see if they can help me. But it seems like I'm almost there. Thanks!

BigFuzzyDog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top