Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    29
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Internet Explorer i got the following error when i am generate the studentid dynamically

    Internet Explorer got the error when i am generating studentid dynamically
    i got the following error when i am generate the studentid dynamically
    Error Type:
    there is no error occur but i not eble to generate the studentID dynamically,By using the following code i am inserted the data in their respective fields but there is no value inserted into the studentID column that is not generated dynamiclly please tell where can i done mistake


    code is

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>ADO - Add DataBase Record</title>
    </head>
    <body>
    <h2>Add Record to a Database Table</h2>

    <%
    on error resume next
    set conn=Server.CreateObject("ADODB.Connection")
    conn.provider="SQLOLEDB.1;Persist Security Info=False;User ID=sa;password=123;Initial Catalog=Student;Data Source=MONTESSO-DFA5BB"
    conn.open

    Set comm=Server.CreateObject("ADODB.Command")
    comm.ActiveConnection=conn
    comm.CommandText="select max(substring(studentID,3,6)) from tblClass"

    set rs=Server.CreateObject("ADODB.Recordset")
    set rs=comm.Execute
    for each x in rs.Fields
    if x.name<>"studentID"
    <%= x.value%>
    response.write(str)


    set str2=str2+1

    set sID="&MS&" +str2

    student Id=sID
    fname=Request.Form("fname")
    lname=Request.Form("lname")
    class1=Request.Form("class")
    section=Request.Form("section")
    emailID=Request.Form("emailID")


    sql="INSERT INTO tblClass (studentID,fname,lname,class,section,emailID) VALUES "
    sql=sql & "('" & studentID &"','" & fname & "','" & lname & "','" & class1 & "','" & section & "',"
    sql=sql & "'" & emailID & "')"

    conn.Execute sql,recordsaffected
    if err <> 0 then
    Response.Write("You do not have permission to update this database!")
    else
    Response.Write(Recordsaffected & " record added")
    end if

    conn.close
    %>
    <form method="post" action="Student_db_new.asp" target="_blank">
    <input type="submit" value="DetailOfTheClassStudents">
    </form>
    </body>
    </html>
    Last edited by prashanth193; 12-18-2011 at 03:36 AM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,901
    Thanks
    79
    Thanked 4,421 Times in 4,386 Posts
    DEBUG DEBUG DEBUG.

    To start with:
    Code:
    ...
    sql="INSERT INTO tblClass (studentID,fname,lname,class,section,emailID) VALUES "
    sql=sql & "('" & studentID &"','" & fname & "','" & lname & "','" & class1 & "','" & section & "',"
    sql=sql & "'" & emailID & "')"
    
    Response.Write "<HR>DEBUG SQL: " & sql & "<HR>" & vbNewLine
    
    ...
    What does that debug show you?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Dec 2011
    Posts
    29
    Thanks
    6
    Thanked 0 Times in 0 Posts
    in the above i mentioned code the value of the substring i got it but i am not able to store that vlaue into another variable.by using that value i will increase one number and concatinate with the string and finally that value will stored in studentID.But only the problem is that how can i store the record set value in to a variable.can u tell me please

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,901
    Thanks
    79
    Thanked 4,421 Times in 4,386 Posts
    I am sorry, but I do not understand at all what you are trying to do.

    Maybe you need to give an example?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New Coder
    Join Date
    Dec 2011
    Posts
    29
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Internet Explorer got the error when i am generating studentid dynamically
    i got the following error when i am generate the studentid dynamically
    Error Type:
    there is no error occur but i not eble to generate the studentID dynamically,By using the following code i am inserted the data in their respective fields but there is no value inserted into the studentID column that is not generated dynamiclly please tell where can i done mistake


    code is

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>ADO - Add DataBase Record</title>
    </head>
    <body>
    <h2>Add Record to a Database Table</h2>

    <%
    on error resume next
    set conn=Server.CreateObject("ADODB.Connection")
    conn.provider="SQLOLEDB.1;Persist Security Info=False;User ID=sa;password=123;Initial Catalog=Student;Data Source=MONTESSO-DFA5BB"
    conn.open

    Set comm=Server.CreateObject("ADODB.Command")
    comm.ActiveConnection=conn
    comm.CommandText="select max(substring(studentID,3,6)) from tblClass"

    set rs=Server.CreateObject("ADODB.Recordset")
    set rs=comm.Execute
    for each x in rs.Fields
    if x.name<>"studentID"
    <%= x.value%>
    response.write(str)


    set str2=str2+1

    set sID="&MS&" +str2

    student Id=sID
    fname=Request.Form("fname")
    lname=Request.Form("lname")
    class1=Request.Form("class")
    section=Request.Form("section")
    emailID=Request.Form("emailID")


    sql="INSERT INTO tblClass (studentID,fname,lname,class,section,emailID) VALUES "
    sql=sql & "('" & studentID &"','" & fname & "','" & lname & "','" & class1 & "','" & section & "',"
    sql=sql & "'" & emailID & "')"

    conn.Execute sql,recordsaffected
    if err <> 0 then
    Response.Write("You do not have permission to update this database!")
    else
    Response.Write(Recordsaffected & " record added")
    end if

    conn.close
    %>
    <form method="post" action="Student_db_new.asp" target="_blank">
    <input type="submit" value="DetailOfTheClassStudents">
    </form>
    </body>
    </html>






    in the above i mentioned code the value of the substring(from MS08 i got 08 value) i got it but i am not able to store that vlaue into another variable.by using that value i will increase one number and concatinate with the string and finally that value will stored in studentID.But only the problem is that how can i store the record set value in to a variable.can u tell me please

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,901
    Thanks
    79
    Thanked 4,421 Times in 4,386 Posts
    Do you know what "EXAMPLE" means?

    I mean I want you to show me what your studentid values look like.

    Are they just numbers? Do they have letters in front of them? Or what.

    But this code MAKES NO SENSE AT ALL:
    Code:
    for each x in rs.Fields
        if x.name<>"studentID"
            <%= x.value%>
            response.write(str)
    
            set str2=str2+1
    
            set sID="&MS&" +str2
    
            student Id=sID
    (1) You have a FOR EACH but you have no NEXT to end the for each.
    (2) You have an IF but you have no END IF
    (3) You can't use <%=...%> when you are *ALREADY* in <%...asp code ... %>
    (4) You response.write(str) but you never give any value to str
    (5) You use SET two places where it is illegal.
    (6) You do str2=str2+1 but you never gave str2 any starting value.

    In short, *ALL* of that code is a complete mess and it will *NOT EVEN COMPILE*. SO it it can't compile, it can't run.

    Right now, you seem to be just throwing code at the wall and hoping that maybe some of it will stick. No, it won't. If you don't write *LEGAL* code, then you have no hope of ever making the code run correctly.


    I think you need to go back and start reading how to write ASP code, from the beginning.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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