Jump to content

jojay

Members
  • Posts

    69
  • Joined

  • Last visited

Posts posted by jojay

  1. Cssn has no value when you use it here:Sqlr="Select * from Cform where Cssn ='"&Cssn&"'"You need to get the value from somewhere (your form maybe) before you use it in the sql statement.

    You mean, using a request.form statement before the sql statement as:
    Cssn = request.form("Cssn")sqlr = "Select * from Cform where Cssn ='"&Cssn&"'"

    I have another database question. In my database I have created a field called ID - primary key. And I have given as autonumber - datatype. The problem I see is if I accidently do a refresh also, it creates another record again and again. My question is, is it good to set up field as autonumber - databatype or is there any other way to solve this issue. I dont want to assign Cssn as primary key becoz there might be some records without the Cssn value. Any suggestion? Thanks.

  2. Sessions: http://www.w3schools.com/asp/asp_sessions.aspto put the current date/time in a session named date
    session("date")=now()

    To retrieve the session and check it agains current date time

    dim thedatethedate=datediff("s",session("date"),now())

    control structure

    if (thedate<120) then     'submitted page less than 2 mins agoresponse.write "error"end if

    something along those lines

    I dont know if I did it right but it doesnt do anything except add the error msg along with my stuff. I added the above code on top of the resultpage.asp, that is the second page, and it didnt do anything and still was add records to the database.
  3. When you first enter the page create a session and put in the current date and time.Then when you enter the page again (pressing refresh etc) check the session and if the page was sumbitted within the last 1day 1week or whatever reject it.If you know what i mean :)

    If you dont mind, can you give an example. I havent used session. thanks.
  4. It depends on what kind of "database" we're taling about. A counter? Well, instead of having detect every single "hit" on the page, the server's script could instead create a sesson variable and count the sessons intead. Or fetch the header information, and count the different IPs.

    Hi,I am working on asp with MS Access. I have a form and trying to connect to the database. It works fine. so, the first page has a form with submit button. when hit the submit button, it goes to resultpage.asp, in which I have put the database connection and recordset codes and I have a table of all the data posted in the form as response.write on the resultpage.asp. I have a print button to print that page. Now, if I hit the refresh button, it again submits the same data to the database. database specs:ID - autonumber - primary key.Any help would be great. Thanks.
  5. I think the problem is my sql statement, can someone tell the correct syntax because when I check the response.write sqlr, it gives me:

    Select * from Cform where Cssn =''No Records for SSN

    database specs:Fieldname - Cssn datatype - text

  6. Can someone please help with code? When I try to run the code, it is going to "No records for SSN". If I dont use the If statament, then I am getting an error message such as :Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.Thanks.

  7. Or you can do like the one below:

    <html><head><title>Button Link</title><script Language="javascript">function link() 	{  window.location = "http://www.somesite.com";	}</script></head><body><form><input type="button" name="button" value="Click Button" onclick="link()"></form></body></html>

  8. File permissions are little different on the internet, you have to make sure both your folder and database have write permissions. Right-clicking and unchecking the "read-only" box won't do anything, you have to chmod whatever folder your database is sitting in, set it to 660 (if that doesn't work, try chmodding it to 777). Most FTP programs will allow you to do that just by right-clicking on the folder and changing its permissions.If the FTP program won't let you chmod folders, then you have to ask your webhost to do it for you.The part that says "0=1" just tells the database not to return any rows, because you're not using them. If you excluded that part, it would force the entire table into the recordset object for no purpose (which is very resource consuming).I just reproduced the same code from your opening post. When you use this:
    Insert into Cform (Cssn,Cjobno,Cfname,Clname,Cphone,Cemail,Cnotes,Cjobref,Cimmsta,Cposition) values ('"&Cssn&"', ...

    Its going to insert the "&Cssn&" into your field. You have that string surrounded in both single quotes, and double quotes. Thats just SQL, here are some more examples:

    Select "&cssn&" From some_table;-> &cssn&Select '"&cssn&"' From some_table;-> "&cssn"Select ""&cssn&"" From some_table;-> "&cssn&"Select ''&cssn&'' From some_table;-> '&cssn&'

    I put double-quotes around the values because I presumed, from your original SQL, that you wanted the string "&cssn&" inserted into your table. I'm not sure why you did, but I just reproduced the SQL code exactly as I read it. But if you were looking to insert form values and not predefined strings, then yes, you would use rs("Cssn") = Request.form("Cssn") :)

    Thank you taking the time to respond to my problem. I got that problem fixed. Inititally, it was Guest user permission, I fixed it going through some searching on Windows XP Professional pages. And Regarding the code you gave, actually it didnt work:
    rs("Cssn") = """&Cssn&"""

    It was going to the database but as "&Cssn&" something like that. It didnt send the value of Cssn to the database. Anyway, I got that working like the one below:

    rs("Cssn") = Cssn

    and it worked. I dont know if it is correct way of coding but it worked. I have another problem displaying data from the database. Below is my code:result.asp

    Set conn = Server.CreateObject("ADODB.Connection")Conn.Open "dsn=Candidate"Set rs1 = Server.CreateObject("ADODB.Recordset")Sqlr="Select * from Cform where Cssn ='"&Cssn&"'" rs1.open Sqlr, conn,3,3If  rs1.EOF Then	Response.write "No Records for SSN"ElseIf not  rs1("Cssn") = "" Then%><table><% Do While Not rs1.EOF %><tr><td>SSN</td><td><%=rs1("Cssn")%></td></tr><tr><td>Job No</td><td><%=rs1("Cjobno")%></td></tr><tr><td>First Name</td><td><%=rs1("Cfname")%></td></tr><tr><td>Last Name</td><td><%=rs1("Clname")%></td></tr></table><%LoopEnd IfEnd ifrs1.closeSet rs1 = nothingconn.closeSet conn = nothing%>

    I am using below code because the Cssn field datatype is Text even though it is a number:

    where Cssn = '" & Cssn & "'

    When I check with Cssn value which is in database, the result page shows as "No record for SSN"

  9. Yeah there aint a great deal of diffrence in the coding between HTML and XHTML it just forces you to code pages better as it has strickter rules.

    As johneva says, the codes are more stricter such as:In html, below code is okay to apply:
    <br>

    In XHTML, it should be:

    <br />

    Attributes should be in lower case such as <table width="100%"> but in html, it can <table width=100%>, DTD Declaration is a must, and so on.

  10. Hi,I am trying to run my asp pages from XP Professional and database is MS Access. I am not able to connect to database using asp codes. I am gettting an error such as " Cannot update, Database or object is Read Only".Can someone please guide me to give the required permission? IIS is 5.0 or 5.1, not sure.I checked right clicking the database and it doesnt say as Read only. And the database is in a folder under wwwroot folder.

  11. If its not a permission problem, its probably a cursortype or locktype problem. This code explicitly specifies to the database that you are going to be updating records:
    Set con = Server.createobject("Adodb.Connection")con.open"dsn=Candidate"Set rs = Server.createobject("Adodb.Recordset")rs.Open "Select Cssn,Cjobno,Cfname,Clname,Cphone,Cemail,Cnotes,Cjobref,Cimmsta,Cposition From CForm Where 0=1", con, 3, 3   rs.Addnew   rs("Cssn") = """&Cssn&"""   rs("Cjobno") = """&Cjobno&"""   rs("Cfname") = """&Cfname&"""   rs("Clname") = """&Clname&"""   rs("Cphone") = """&Cphone&"""   rs("Cemail") = """&Cemail&"""   rs("Cnotes") = """&notes&"""   rs("Cjobref") = """&Cjobref&"""   rs("Cimmsta") = """&Cimmsta&"""   rs("Cposition") = """&Cposition&""   rs.Updaters.closeCon.close

    Hi,I guess the code is going through good but I am having another error such as:Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only. I right clicked the database and checked the properties and it doesnt says Read only- the Read Only checkbox is unchecked. What is this problem? Where should I see if the database has the write permission.And so, with your code, I have a question regarding the where 0 = 1" ? What does it say, is it some similar to where cssn = '"& cssn&"'And secondly, why is the rs("Cssn") = """&Cssn&""" has so many double quotes. Will this okay to use:rs("Cssn") = Request.form("Cssn")What is the difference?
  12. Hi,I am working on a simple asp form to send info from form to the database and I am getting this error and went around to find some articles and found that this could be due to persmission problem, etc. I checked all that and that isnt the issue. Can some one please explain why I get this error?My conection code:

    Set con = Server.createobject("Adodb.Connection")con.open"dsn=Candidate"Set rs = Server.createobject("Adodb.Recordset")rs = con.execute ("Insert into Cform (Cssn,Cjobno,Cfname,Clname,Cphone,Cemail,Cnotes,Cjobref,Cimmsta,Cposition) values ('"&Cssn&"','"&Cjobno&"','"&Cfname&"','"&Clname&"','"&Cphone&"','"&Cemail&"','"&Cnotes&"','"&Cjobref&"','"&Cimmsta&"','"&Cpostion&"')")

    error:Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query

  13. Hi,I would like to know if there is any place where I can try out the .net codings while I learn. I am learning from home and dont have the necessary softwares to run my codes. any suggestion would be great. thanks.

×
×
  • Create New...