Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Notes and SQL

Posted on 1998-10-21
6
202 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

  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…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 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