Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 6th, 2004, 02:42 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
Default shoakat

Hello Guys,I am writing the asp page with sql server. I am
using two obj. The employee and manager, i want to get the out put
with employee reporting to different manager. I am really tired. If you see my code.
 Dim objConn
    Dim objRST
    set objConn= Server.CreateObject("ADODB.Connection")
    set objRST = Server.CreateObject("ADODB.Recordset")
    strConnection="DATABASE=NORTHWIND;DSN=shoakatdb;UI D=shoakat;Password=shoakat"
    'objRST.CursorLocation=3
    strR =Request.QueryString("EmployeeID")
    strNumber="SELECT * From Employees where employeeID=" & strR
    objConn.Open(strConnection)
    objRST.Open strNumber,objConn,3,3


        if not objRST.EOF then
        strID =objRST.Fields("EmployeeID")
        strLName = objRST.Fields("LastName")
        strFName = objRST.Fields("FirstName")
        strTitle = objRST.Fields("Title")
        strTitleOfCourtesy = objRST.Fields("TitleOfCourtesy")
        strBirthDate = objRST.Fields("BirthDate")
        strHireDate = objRST.Fields("HireDate")
        strAddress = objRST.Fields("Address")
        strCity = objRST.Fields("City")
        strRegion = objRST.Fields("Region")
        strPostalCode =objRST.Fields("PostalCode")
        strCountry=objRST.Fields("Country")
        strHomePhone = objRST.Fields("HomePhone")
        strReports = objRST.Fields("ReportsTo")
        strNotes = objRST.Fields("Notes")

        else
        end if

    if Request.Form("txtMode")="A" then
      strID=""
      strLName=""
      strFName=""
      strTitle=""
      strTitleOfCourtesy=""
      strBirthDate=""
      strHireDate=""
      strAddress=""
      strCity=""
      strRegion=""
      strPostalCode =""
      strCountry=""
      strHomePhone=""
      strReports=""
      strNotes =""
      else
      end if

    if Request.Form("txtMode")="B" then
    objRST.Delete()
    strID=""
    strLName=""
    strFName=""
    strTitle=""
    strTitleOfCourtesy=""
    strBirthDate=""
    strHireDate=""
    strAddress=""
    strCity=""
    strRegion=""
    strPostalCode =""
    strCountry=""
    strHomePhone=""
    strReports=""
    strNotes =""
    else
    end if

   if Request.Form("txtMode")= "C" then
     if Request.Form("txtID")="" then
     objRST.AddNew()
     end if
      strFName=Request.Form("txtFName")
      strLName=Request.Form("txtLName")
      strBirthDate=Request.Form("txtBDate")
      strHireDate=Request.Form("txtHDate")
      strAddress = Request.Form("txtAddress")
      strCity = Request.Form("txtCity")
      strPostal=Request.Form("txtPostal")
      strTitle=Request.Form("OPinionasp")
      strRegion= Request.Form("txtRegion")
      strCountry=Request.Form("txtCountry")
      strTitleOfCourtesy=Request.Form("ASPOpinion")

      objRST.Fields("FirstName")=strFName
      objRST.Fields("LastName")=strLName
      objRST.Fields("BirthDate")=strBirthDate
      objRST.Fields("HireDate")=strHireDate
      objRST.Fields("Address") = strAddress
      objRST.Fields("City")=strCity
      objRST.Fields("PostalCode")=strPostal
      objRST.Fields("Title")=strTitle
      objRST.Fields("TitleOfCourtesy")=strTitleOfCourtes y
      objRST.Fields("Region")=strRegion
      objRST.Fields("Country")=strCountry
      objRST.Update()
      end if


     'if IsDate(strBirthDate)<>false then
          'return true
     'else
        'return false
     'end if


     objRST.Close
     set objRST = nothing


%>


     <script language = javascript>
      function callMe(){
      thisForm.action='SearchEmp.asp';
      thisForm.submit();
      }
      </script>


      <table border = 1>
    <tr>
       <td>EmployeeID</td>
       <td colspan=4><Input name = "txtID" value ='<%=strID%>'></td>
    </tr>

    <tr>
       <td>LastName</td>
       <td><Input name = "txtLName" value ='<%=strLName%>'></td>
       <td>FirstName</td>
       <td><Input name ="txtFName" value ='<%=strFName%>'></td>
    </tr>

    <tr>
      <td>Title</td>
      <td><SELECT Name=OPinionASp>
               <OPTION value ="" > <%=strTitle%> </OPTION>
               <OPTION name="">Vice President Sales
               <OPTION name ="">Sales Manager
               <OPTION name ="">Sales Cordinator </td>

         </SELECT>

     <td>Title Of Courtesy</td>
     <td><SELECT NAME =ASPOpinion>
              <OPTION value =""> <%=strTitleOfCourtesy%> </OPTION>
              <OPTION name ="">Mr
              <OPTION name ="">Miss
              <OPTION name ="">MRS</td>

       </SELECT>
    </tr>

    <tr>
      <td>Birthdate</td>
      <td><Input name ="txtBDate" value ='<%=strBirthdate%>'></td>
      <td>HireDate</td>
      <td><Input name ="txtHDate" value='<%=strHireDate%>'></td>
    </tr>

    <tr>
      <td>Address</td>
      <td><Input name ="txtAddress" value='<%=strAddress%>'></td>
      <td>City</td>
     <td><Input name ="txtCity" value ='<%=strCity%>'></td>
    </tr>


    <tr>

      <td>Region</td>
      <td><SELECT NAME = txtRegion>
              <OPTION value =""> <%=strRegion%> </OPTION>
              <OPTION name =""> MN
              <OPTION name =""> WA
              <OPTION name =""> MA
              <OPTION name =""> NULL </td>
       </SELECT>

     <td>Postal Code</td>
     <td><Input name = "txtPostal" value='<%=strPostalCode%>'></td>
    </tr>

    <tr>

      <td>Country</td>
      <td><SELECT NAME = txtCountry>
              <OPTION value =""> <%=strCountry%> </OPTION>
              <OPTION name =""> USA
              <OPTION name =""> UK
              <OPTION name =""> NULL</td>
       </SELECT>

      <td></td>
      <td> </td>

    </tr>


  <%

    Dim objCmd
    Dim objManager
    set objCmd = Server.CreateObject("ADODB.Command")
    set objManager = Server.CreateObject("ADODB.Recordset")

    objCmd.ActiveConnection = objConn
    objCmd.CommandText = "get_otherNames"
    objCmd.CommandType = 4
    set objParam1=objCmd.CreateParameter("")

   objParam1.Type= 3
   objParam1.Value = strR
   objParam1.Direction = 1
   objParam1.Size =4
   objCmd.Parameters.Append(objParam1)
   set objManager = objCmd.Execute()
   %>
    <tr>
    <td>Reports To</td>
    <td><SELECT NAME = Manager>

       <% do while not objManager.EOF
            strEmpId = objManager.Fields("EmployeeID")
            strReports = objManager.Fields("ReportsTo")
            strMgrName = objManager.Fields("FullName")

            if objManager.Fields("EmployeeID")=1 then
                 strMgrName1= "hereup1"
                end if


               if objManager.Fields("EmployeeID")=2 then
                   strMgrName1="hereup1"
               end if


               if objManager.Fields("EmployeeID")=3 then
                   strMgrName1 = "hereup1"
                end if


            'end if



             if objManager.Fields("EmployeeID")=4 then
                   strMgrName1="steven"
             end if




              if objManager.Fields("EmployeeID")=5 then
                   strMgrName1 ="stevem"
            end if



               if objManager.Fields("EmployeeID")>=6 then
                  strMgrName1 = "null"
            end if
         %>
           <OPTION VALUE =<%="strMgrName"%>><%=strMgrName1%></OPTION>

          <%objManager.MoveNext()
          loop




       objManager.Close
       objConn.Close
       set objManager = nothing
       set objCmd = nothing
       set objConn = nothing
       %>
        </Select>

     </tr>
     <tr>
        <Center>
      <td>Notes</td>
      <td><textarea rows="8" cols="13" name=textarea1 '<%=strNotes%>'>
       </textarea>
       </tr>




    <tr>
      <td><Input type ="submit" value=CreateNew onclick=thisForm.txtMode.value='A';></td>
      <td><Input type ="submit" value=Save onclick=thisForm.txtMode.value='C'></td>
      <td><Input type ="submit" value=Delete onclick=thisForm.txtMode.value='B'; ></td>
      <td><Input type ="submit" value=BackToSearch onclick= "javascript:callMe();" ></td>
          <Input type ="hidden" name =txtMode>

    </tr>


    </table>
    </BODY>
    </HTML>
    </FORM>


 
Old August 6th, 2004, 03:37 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<% do while not objManager.EOF
            strEmpId = objManager.Fields("EmployeeID")
            strReports = objManager.Fields("ReportsTo")
            strMgrName = objManager.Fields("FullName")

            if objManager.Fields("EmployeeID")=1 then
                 strMgrName1= "hereup1"
                end if


               if objManager.Fields("EmployeeID")=2 then
                   strMgrName1="hereup1"
               end if


               if objManager.Fields("EmployeeID")=3 then
                   strMgrName1 = "hereup1"
                end if


            'end if



             if objManager.Fields("EmployeeID")=4 then
                   strMgrName1="steven"
             end if




              if objManager.Fields("EmployeeID")=5 then
                   strMgrName1 ="stevem"
            end if



               if objManager.Fields("EmployeeID")>=6 then
                  strMgrName1 = "null"
            end if
         %>
           <OPTION VALUE =<%="strMgrName"%>><%=strMgrName1%></OPTION>

          <%objManager.MoveNext()
          loop
 Concentrate on the above code. I am wrong somewhere at the top.





 
Old August 6th, 2004, 09:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi there,

I would suggest you to place a subject that is relavant/suits to your post(not just your name, as one could see in all your posts), that will help people who searching for solutions in future to easily identify your post by it subject. Also don't just post your entire code, than you can explain on what you are looking for and post the code only if needed. It is not the easiest job to go through one's code and suggest something without knowing what it actually does. Ans with limited info it is the toughest job in this world.

Can you post some info on the backend - on the structure of Employee/Manager table? Also, I am not sure, why you use hardcoded values like 1 to 6 and steven/hearup1? Are those values fixed? What does 1 - 6 mean? What does get_otherNames proc do?

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
shoakat shoakat Classic ASP Databases 9 September 2nd, 2004 06:14 PM
Shoakat shoakat Classic ASP Databases 4 August 4th, 2004 06:46 AM
shoakat shoakat Classic ASP Databases 0 August 3rd, 2004 11:07 AM
shoakat shoakat Classic ASP Databases 2 July 28th, 2004 03:59 PM
shoakat shoakat Classic ASP Databases 4 July 26th, 2004 04:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.