ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

ASP - anyone have a simple workin ex.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ASP - anyone have a simple workin ex.

    Im looking for a simple working example of an ASP page connecting and showing
    data from the iseries -- I assume it would use Provider=IBMDA400

    I did this 200 years ago and cant get it working now.


    thanks in advance

    jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

  • #2
    Re: ASP - anyone have a simple workin ex.

    Jamie,

    Pls see
    Thanks,
    Giri

    Comment


    • #3
      Re: ASP - anyone have a simple workin ex.

      Thanks I saw this but I was looking for an example that I could just change the
      library file name and get a test ap up and running.


      thanks
      jamie
      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment


      • #4
        Re: ASP - anyone have a simple workin ex.

        Code:
        <%@ LANGUAGE="VBScript" %>
        <% 
        	Option Explicit
        	Dim sDB2String,UID, SQLStmt, Connection, FirstName, LastName
        	Dim RS, ProspectNum
        	ProspectNum = Request.QueryString("ProspectNum")
        	Set Connection = Server.CreateObject("ADODB.Connection")
        	Connection.Open "Provider=IBMDA400;User ID=xxxxx;Password=xxxxxxx;Data Source=xxxxxx;"
        	SQLStmt = "SELECT PROSPECTNUM, FIRSTNAME, LASTNAME FROM prospectfile FETCH FIRST 10 ROWS ONLY"
        	Set RS = Connection.Execute(SQLStmt)
        %>
        
        <html>
        <title>Prospect details</title>
        <BODY BGCOLOR="FFFFFF">
        
        <hr>
        <font face="arial" size=2>
        <h1>Prospect Information</h1>
        
        <%	Do While Not RS.EOF%>
        <h2>Here is the prospect Information for <%= RS.Fields("Firstname") %> <%= RS.Fields("Lastname") %>:</h2>
        <b>First Name:</b> <%= RS.Fields("Firstname") %><p>
        <b>Last Name:</b> <%= RS.Fields("Lastname") %><p>
        <b>Prospect Number:</b> <%= RS.Fields("Prospectnum") %><p>
        <%	RS.MoveNext
        	Loop
        %>
        
        <hr>
        </body>
        </html>
        <%	Connection.Close %>
        \
        Thanks,
        Giri

        Comment


        • #5
          Re: ASP - anyone have a simple workin ex.

          I tested the above code and is working ...
          Thanks,
          Giri

          Comment


          • #6
            Re: ASP - anyone have a simple workin ex.

            Thanks giri I will play with this in the morning

            jamie
            All my answers were extracted from the "Big Dummy's Guide to the As400"
            and I take no responsibility for any of them.

            www.code400.com

            Comment


            • #7
              Re: ASP - anyone have a simple workin ex.

              Hey Giri nice job this works fine - just have to pretty up the HTML and
              format the data.....

              I do have one question about the fields, some of our iseries data fields contain
              the # sign will this be an issue?


              jamie
              Attached Files
              All my answers were extracted from the "Big Dummy's Guide to the As400"
              and I take no responsibility for any of them.

              www.code400.com

              Comment


              • #8
                Re: ASP - anyone have a simple workin ex.

                Its not an issue Jamie .....
                Thanks,
                Giri

                Comment


                • #9
                  Re: ASP - anyone have a simple workin ex.

                  Bent this is an issue for you tooo

                  what is wrong with my if statement -- and --
                  how the FRIG is it writting to the browser without the
                  Response.Write opcode????



                  Code:
                  	Dim sDB2String,UID, SQLStmt, Connection, FULLNAME, DEPARTMENT, LASTNAME , EXTENSION, PHONE
                  	Dim RS
                        Dim Savedepartment
                  	LASTNAME = Request.QueryString("LASTNAME")
                  	Set Connection = Server.CreateObject("ADODB.Connection")
                  	Connection.Open "Provider=IBMDA400;User ID=?????;Password=?????;Data Source=XX.XX.X.X;"
                  	SQLStmt = "SELECT LASTNAME, FULLNAME, DEPARTMENT, LASTNAME, EXTENSION, PHONE FROM JAMIELIB.PHONEP order by DEPARTMENT ,LASTNAME"
                  	Set RS = Connection.Execute(SQLStmt)
                  %>
                  
                  <html>
                  <title>Prospect details</title>
                  <BODY BGCOLOR="FFFFFF">
                  
                  <hr>
                  <font face="arial" size=2>
                  <h1>The Phone List</h1>
                  
                  <%	Do While Not RS.EOF%>
                  
                  If savedepartment  = ' ' or savedepartment = RS.Fields("DEPARTMENT") Then
                  <h2>Department <%= RS.Fields("DEPARTMENT") %></h2>
                  savedepartment = RS.Fields("DEPARTMENT") 
                  End If
                  
                  
                  <b>Name:</b> <%= RS("FULLNAME") %><p>
                  <b>Phone:</b> <%= RS("PHONE") %><p>
                  <b>EXTENSION:</b> <%= RS("EXTENSION") %><p>
                  <%	RS.MoveNext
                  	Loop
                  %>
                  
                  <hr>
                  </body>
                  </html>
                  <%	Connection.Close %>
                  Last edited by jamief; December 12, 2006, 03:58 PM. Reason: second question added
                  All my answers were extracted from the "Big Dummy's Guide to the As400"
                  and I take no responsibility for any of them.

                  www.code400.com

                  Comment


                  • #10
                    Re: ASP - anyone have a simple workin ex.

                    u need to put ur if condition between <% and %> like do while condition.

                    u dont need reponse.write ....
                    bcse its couple of html tags
                    Thanks,
                    Giri

                    Comment


                    • #11
                      Re: ASP - anyone have a simple workin ex.

                      Okay That was a newbie question

                      one more how do I reference the fields from the sql select.

                      in some kind of if else statement
                      dont care weather its Java script or vb script just need to get 'running..

                      Thanks so much for the help
                      jamie
                      All my answers were extracted from the "Big Dummy's Guide to the As400"
                      and I take no responsibility for any of them.

                      www.code400.com

                      Comment


                      • #12
                        Re: ASP - anyone have a simple workin ex.

                        here is my example I have a simple one field form I want to take that one
                        field and write to iseries table

                        Code:
                        <%@ LANGUAGE="VBScript" %>
                        <% 
                        	Option Explicit
                        	Dim sDB2String,UID, sqlstmt, Connection 
                        	Dim RS
                                Dim SaveDepartment
                        	Set Connection = Server.CreateObject("ADODB.Connection")
                        	Connection.Open "Provider=IBMDA400;User ID=xxx;Password=xxx;Data Source=10.10.10.10;"
                        %>
                        <form action="form.asp" method="post">
                        Your name: <input type="text" name="fname" size="20" />
                        <input type="submit" value="Submit" />
                        </form>
                        <%
                        dim fname
                        fname=Request.Form("fname")
                        If fname<>"" Then
                        sqlstmt = "insert into JAMIELIB.PHONEP (FULLNAME) values(" & fname & "))" 
                        set RS = Connection.Execute(sqlstmt)
                        End If
                        %>
                        error
                        Error Type:
                        IBMDA400 Command (0x80004005)
                        SQL0104: Token ) was not valid. Valid tokens: <END-OF-STATEMENT>. Cause . . . . . : A syntax error was detected at token ). Token ) is not a valid token. A partial list of valid tokens is <END-OF-STATEMENT>. This list assumes that the statement is correct up to the token. The error may be earlier in the statement, but the syntax of the statement appears to be valid up to this point. Recovery . . . : Do one or more of the following and try the request again: -- Verify the SQL statement in the area of the token ). Correct the statement. The error could be a missing comma or quotation mark, it could be a misspelled word, or it could be related to the order of clauses. -- If the error token is <END-OF-STATEMENT>, correct the SQL statement because it does not end with a valid clause.
                        /form.asp, line 21
                        I can insert all text literals and it workd fine...just would like to know how to reference the field fname from the form and write this to table.

                        thanks
                        jamie
                        All my answers were extracted from the "Big Dummy's Guide to the As400"
                        and I take no responsibility for any of them.

                        www.code400.com

                        Comment


                        • #13
                          Re: ASP - anyone have a simple workin ex.

                          Okay this works......kinda cool... currently it writes with only one field
                          populated (full name).

                          DDS on the iseries
                          PHP Code:
                                *     outqueue file               
                               A          R PHONER                
                               A            FIRSTNAME     30A     
                               A            LASTNAME      40A     
                               A            FULLNAME      75A     
                               A            DEPARTMENT    25A     
                               A            EXTENSION      4      
                               A            PHONE         12      
                                                                  
                               A          K LASTNAME 




                          Code:
                          <%@ LANGUAGE="VBScript" %>
                          <% 
                          	Option Explicit
                          	Dim sDB2String,UID, sqlstmt, Connection 
                          	Dim RS
                                  Dim Formname
                          	Set Connection = Server.CreateObject("ADODB.Connection")
                          	Connection.Open "Provider=IBMDA400;User ID=xxxxx;Password=xxxxxxxx;Data Source=10.10.10.10;"
                          %>
                          <form action="form.asp" method="post">
                          Your name: <input type="text" name="fname" size="20" />
                          <input type="submit" value="Submit" />
                          </form>
                          <%
                          dim fname
                          fname=Request.Form("fname")
                          If fname<>"" Then
                                Response.Write("Hello " & fname & "!<br />")
                                Response.Write("How are you today?")
                          FormName = Request.Form("fname")
                          sqlstmt = "insert into JAMIELIB.PHONEP (FULLNAME) values('" & Formname & "')" 
                          set RS = Connection.Execute(sqlstmt)
                          End If
                          %>
                          All my answers were extracted from the "Big Dummy's Guide to the As400"
                          and I take no responsibility for any of them.

                          www.code400.com

                          Comment

                          Working...
                          X