Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    9

    Unanswered: Date problem of Oracle through ASP

    Hi All,

    I'm trying to store the Date in Oracle Table through ASP. I'm generating the <select><option> for the date through oracle table only. my code is like this

    <tr><td align=center>Date of Join:</td><td align=left>
    <%
    dim sql3
    set rs6=Server.CreateObject("ADODB.recordset")

    sql3="Select gen_date from dategen"
    sql3=sql3&" where gen_date is not null"
    rs6.open sql3, conn
    %>

    <select name="d_date">
    <%do until rs6.EOF %>
    <option <%if d_date=rs6(0).Value then Response.Write("selected") end if%> ><%=rs6(0).Value %> </option>
    <%
    rs6.MoveNext
    loop
    rs6.Close
    set rs6=Nothing %>
    </select>
    <%
    dim sql4
    set rs7=server.CreateObject("ADODB.recordset")
    sql4="select gen_month from dategen"
    sql4=sql4& " where gen_month is not null"
    rs7.Open sql4,conn
    %>
    <select name="d_month">
    <% do until rs7.EOF %>
    <option <% if d_month=rs7(0).Value then Response.Write("selected") end if %> >
    <%=rs7(0).Value%></option>
    <% rs7.MoveNext
    loop
    rs7.Close
    set rs7=nothing %>
    </select>
    <%
    dim sql5
    set rs8=Server.CreateObject("ADODB.recordset")

    sql5="Select gen_year from dategen where gen_year is not null"
    rs8.open sql5, conn
    %>

    <select name="d_year">
    <%do until rs8.EOF %>
    <option <%if d_year=rs8(0).Value then Response.Write("selected") end if%> >
    <%=rs8(0).Value %> </option>
    <%
    rs8.MoveNext
    loop
    rs8.Close
    set rs8=Nothing %>
    </select>
    </td></tr>

    and while inserting I'm calling another page there I'm wrinting code like this

    <%
    dim doj
    doj=Request.Form("d_date")&"-"&Request.Form("d_month")&"-"&Request.Form("d_year")
    sql="INSERT INTO emp (emp_id,emp_name,gender,doj,grade)"
    sql=sql & " VALUES "
    sql=sql & "('" & Request.Form("emp_id") & "',"
    sql=sql & "'" & Request.Form("emp_name") & "',"
    sql=sql & "'" & Request.Form("gender") & "',"
    sql=sql & "'" & doj &"',"
    sql=sql & "'" & Request.Form("grade") & "')"
    on error resume next
    conn.Execute sql
    if err<>0 then
    Response.Write("<h3 align=center style='letter-spacing:3px'>Due to Errors in Input Record is not Added !</h3>")
    else
    Response.Write(doj)
    end if
    conn.close
    %>

    it is working fine untill I select the year upto 2000. for example if I select the year 2000 jan 1st It is storing the values in table like this "20-JAN-01" . It is taking year value as date value. As I know there is no wrong in assigning values to variables.

    somebody plz help. thanx in advance.

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    What is an example of what the variable doj acutally has stored in it ? What do the values look like on the page ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •