Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Notes and SQL

Posted on 1998-10-21
6
Medium Priority
?
209 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 150 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Loops Section Overview
Suggested Courses
Course of the Month12 days, 14 hours left to enroll

971 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