Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Notes and SQL

Posted on 1998-10-21
6
Medium Priority
?
208 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
[X]
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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

719 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