Solved

Notes and SQL

Posted on 1998-10-21
6
198 Views
Last Modified: 2013-12-18
     I need  to build an application to access data from an SQL database. I´ve made an application that makes an SQL query to an SQL database , but the code is entirely in an agent.  And it shows the results in messageboxes.
      I´d like to have a screen with a field where someone can fill with the name to be searched, and this name should be passed to the agent. I´d like to show the results in the format of a table too.
      I was thinking that if I create a field in a form, in order to people type the name to be searched , it would work, but Notes always ask me to save the document, and I don´t want to have one document for each query people make.
      I thought about creating a field in a navigator, so that Notes wouldn´t ask me to save the document. But it doesn´t let me create a field in a navigator.
      How can I make it? How can I pass a parameter filled by an user to an agent ?
      And how can I format the results in a table , using lotus script ?
      Have anybody done an application like this ?

                                    Thanks in advance !
                                    Priscila
0
Comment
Question by:ptenuta
  • 3
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
wrichard earned 50 total points
ID: 1117581
To pass the value of a field to the agent that you wrote you will need to have the triggering action (i.e. push button, field exit) write the value of that field to the Notes.INI file by using the session.setenvironmentstring and then read the value from the agent.  An easier solution would be to move your agent code into a push button that will read the value from the uidoc directly into the script and then execute the query.  As far as writing the results in a table, you will have to parse through the result set in script and populate the different variables using the values from the result set, Chr(10) (new line), and & (concatenate).  Once you have finished populating the variables you can write them back to the form using  the uidoc class.
0
 

Author Comment

by:ptenuta
ID: 1117582
Ok. So let´s concentrate on the easier solution . Here is the code (executed when a user clicks a button) I´ve built until now:

Dim Workspace As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Dim research As String
     Dim con As New ODBCConnection
     Dim qry As New ODBCQuery
     Dim result As New ODBCResultSet
     Set uidoc = workspace.CurrentDocument
     pesquisa = uidoc.FieldGetText("name")
     If con.ConnectTo("database") Then
          Set qry.Connection = con
          qry.SQL = "SELECT EName FROM Employees where EName LIKE" & "research" - > this doesn´t work . How can I reference to a variable here ?????
         .
         .
         .

0
 
LVL 1

Expert Comment

by:wrichard
ID: 1117583
If research is a value that is going to be taken from the uidoc then refernece it from the uodoc class:
qry.SQL = "SELECT EName FROM Employees where EName LIKE '" & uidoc.FieldGetText("research") & "'".
If it is a variable that has been set inside your script then reference it without quotes:
pesquisa = uidoc.FieldGetText("name")
qry.SQL = "SELECT EName FROM Employees where EName LIKE '" & pesquisa & "'"

If you notice I have appended and prepended single quotes around the variables.  When you reference a string via the sql query you need single quotes around it. If you reference a number you do not need single quotes.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:ptenuta
ID: 1117584
I´m still having problems with this part of the problem :
          pesquisa = uidoc.FieldGetText("name")
          qry.SQL = "SELECT EName FROM Employees where EName LIKE '" & pesquisa & "'"

If I put this code :
          qry.SQL = "SELECT EName FROM Employees where EName LIKE 'Priscilla Tenuta'"
it works perfectly.
But when I type the same name in the field, it does not work. It returns "false" . Why is that ?
0
 
LVL 1

Expert Comment

by:wrichard
ID: 1117585
I would run the program through the debug mode (debug lotus script) and view the qry section of variables.  Look at the sql variable in that section and see exactly what is being stored in that variable and what is being passed to the SQL server.
0
 

Expert Comment

by:Shirish
ID: 1117586
Priscilla,
Passing the value  via environment variables would work.
If your variable is of string or variant type, you will have to include single quotes before and after the variable name.
Eg.
qry.SQL = "SELECT * FROM EmpInformation WHERE Location = '" & varname & "'"
One way of debugging SQL statements is to display them using a Message or Input box, just before executing them in Notes and running them in the RDBMS SQL tool separately.
Eg.
teststring = "SELECT * FROM EmpInformation WHERE Location = '" & uidoc.FieldGetText("name") & "'"
MessageBox teststring
qry.SQL = teststring
etc.

Use the methods in ResultSet Class such as GetValue,NextRow, etc to obtain results and format using Chr(10), New line, etc
Hope this helps

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now