Jump to content

quyen

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by quyen

  1. i'm trying to create a new record in ms access. i have page 1) which requests users information in a form, and page 2) which should create the actual record for the database. i'm not sure how to execute this(take a look at 'what should I include here to insert record into database? section in page 2), please take a look at my code, thanks Page 1)-asks users to insert information into a form<%language="vbscript"%><!--#include file="connections.asp"--><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"><!--body { background-color: #996600;}--></style><basefont face="cursive"></head><body><h1 align="center"> Discussion Forum </h1><table border="1" width="100%" bgcolor="#fff5ee"><tr><%for each x in rs.Fields response.write("<th align='left' bgcolor='#b0c4de'>" & x.name & "</th>")next%></tr><%do until rs.EOF%> <tr> <%for each x in rs.Fields%> <td><%Response.Write(x.value)%></td> <%next rs.MoveNext%> </tr><%looprs.closeconn.close%></table><form action="forumCommentAdd2.asp" method="post"><table border = "1" width = 50% align="center"> <tr> <td align="center">Post a message </td> <tr> <tr> <td>Enter Name:<input type="text" name="name"> Date:<input type="text" name="date"></td> </tr> <tr> <td>Comment:<textarea name="comment" cols="35" rows="6" wrap="physical"></textarea></td> <tr> <tr> <td align="center"><input type="submit" name="addComment" value="Post Message"></td> </tr></table></form></body></html></body></html>Page 2) this is the forumAddComment2.asppagewhichshould insert the new record into database<%@language="vbscript"%><!--#include file="connections.asp"--><%'what should I include here to insert record into database?%><html><head><title>SQL Add record example</title></head><body><h2 align="center">Your comments have been added to the forum</h2><br><br><p align="center"><a href="forum.asp">Return to Discussion Forum </a></p></body></html>

  2. I'm having problems with a file that doesn't stop loading. There are two files, the first is the connection info placed in a connections folder

    <%MM_school_STRING = "dsn=school;"%>The other is an asp file that allows the user to make changes to records in an MS access database.  Here is the code.  Can anyone work out why it doesn't stop loading, i've been working on it for hours.  I know it is long, but any help would be deeply appreciated.  Thanks<%@LANGUAGE="VBSCRIPT"%><!--#include file="Connections/school.asp" --><%'Retrieve values from the formaction=request("action")teacherID=request("teacherID")firstname=request("firstname")lastname=request("lastname")dept=request("dept")if action="Add" then 	set command1=Server.CreateObject("ADODB.Command")	command1.ActiveConnection = MM_school_STRING	command1.CommandText="INSERT INTO teacher (firstname,lastname,dept) VALUES ('" & firstname & "','" & lastname & "'," & dept & ")"	command1.execute	command1.ActiveConnection.Closeend ifif action="Modify" then 	set command1=Server.CreateObject("ADODB.Command")	command1.ActiveConnection = MM_school_STRING	command1.CommandText="UPDATE teacher SET firstname='" & firstname & "', lastname='" & lastname & "', dept=" & dept & " WHERE teacherID=" & teacherID 	command1.execute	command1.ActiveConnection.Closeend ifif action="Delete" then 	set command1=Server.CreateObject("ADODB.Command")	command1.ActiveConnection = MM_school_STRING	command1.CommandText="DELETE FROM teacher Where teacherID=" & teacherID 	command1.execute	command1.ActiveConnection.Closeend if%><%set teacher = Server.CreateObject("ADODB.Recordset")teacher.ActiveConnection = MM_school_STRINGteacher.Source = "SELECT * FROM teacher"teacher.CursorType = 0teacher.CursorLocation = 2teacher.LockType = 3teacher.Open()teacher_numRows = 0%><%set dept = Server.CreateObject("ADODB.Recordset")dept.ActiveConnection = MM_school_STRINGdept.Source = "SELECT * FROM dept"dept.CursorType = 0dept.CursorLocation = 2dept.LockType = 3dept.Open()dept_numRows = 0%><%Dim Repeat1__numRowsRepeat1__numRows = -1Dim Repeat1__indexRepeat1__index = 0teacher_numRows = teacher_numRows + Repeat1__numRows%><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body bgcolor="#FFFFFF" text="#929292" background="pictures/BACK.jpg"><p> </p><p> </p><p> </p><p> </p><table width="100%" border="2" bgcolor="#FEFAED" bordercolor="#E3B660">  <tr>     <td width="20%"><b><span teacher="style7">TeacherID:</span></b></td>    <td width="21%"><b><span teacher="style7">Firstname:</span></b></td>    <td width="23%"><b><span teacher="style7">Lastname:</span></b></td>    <td width="22%"><b><span teacher="style7">Dept:</span></b></td>    <td width="14%"> </td>  </tr>    <% While ((Repeat1__numRows <> 0) AND (NOT teacher.EOF)) %>  <tr>  <form name="form1" method="post" action="">     <td width="20%">       <input type="text" name="teacherID" readonly value="<%=(teacher.Fields.Item("teacherID").Value)%>">    </td>    <td width="21%">       <input type="text" name="firstname" value="<%=(teacher.Fields.Item("firstname").Value)%>">    </td>    <td width="23%">       <input type="text" name="lastname" value="<%=(teacher.Fields.Item("lastname").Value)%>">    </td>    <td width="22%">       <select name="dept" size="1">        <%While (NOT dept.EOF)%>        <option value="<%=(dept.Fields.Item("deptID").Value)%>" <%if (CStr(dept.Fields.Item("deptID").Value) = CStr(teacher.Fields.Item("dept").Value)) then Response.Write("SELECTED") : Response.Write("")%>><%=(dept.Fields.Item("name").Value)%></option>        <%  dept.MoveNext()WendIf (dept.CursorType > 0) Then  dept.MoveFirstElse  dept.RequeryEnd If%>      </select>    </td>    <td width="14%">       <input type="submit" name="action" value="Modify">      <input type="submit" name="action" value="Delete">    </td>	</form>  </tr>    <%   Repeat1__index=Repeat1__index+1  Repeat1__numRows=Repeat1__numRows-1  teacher.MoveNext()Wend%>  <tr>  <form name="form2" method="post" action="">     <td width="20%"> </td>    <td width="21%">       <input type="text" name="firstname">    </td>    <td width="23%">       <input type="text" name="lastname">    </td>    <td width="22%">       <select name="select" size="1">        <%While (NOT dept.EOF)%>        <option value="<%=(dept.Fields.Item("deptID").Value)%>" ><%=(dept.Fields.Item("name").Value)%></option>        <%  dept.MoveNext()WendIf (dept.CursorType > 0) Then  dept.MoveFirstElse  dept.RequeryEnd If%>      </select>    </td>    <td width="14%">       <input type="submit" name="action" value="Add">    </td>	</form>  </tr></table><p> </p><table width="98%" border="0">  <tr>     <td width="27%"> </td>    <td width="9%"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="107" height="18">        <param name=movie value="button9.swf">        <param name=quality value=high>        <param name="BGCOLOR" value="">        <embed src="button9.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="107" height="18" bgcolor="">        </embed>       </object></td>    <td width="11%"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="107" height="18">        <param name=movie value="button2.swf">        <param name=quality value=high>        <param name="BGCOLOR" value="">        <embed src="button2.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="107" height="18" bgcolor="">        </embed>       </object></td>    <td width="11%"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="107" height="18">        <param name=movie value="button4.swf">        <param name=quality value=high>        <param name="BGCOLOR" value="">        <embed src="button4.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="107" height="18" bgcolor="">        </embed>       </object></td>    <td width="11%"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="107" height="18">        <param name=movie value="button5.swf">        <param name=quality value=high>        <param name="BGCOLOR" value="">        <embed src="button5.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="107" height="18" bgcolor="">        </embed>       </object></td>    <td width="31%"> </td>  </tr></table><p> </p></body></html><%teacher.Close()%><%dept.Close()%>

    [edit] wrapped code in codebox - skemcin

  3. hi,i was wondering if someone could tell me whether it is necessary to include the connect key word on every asp page or would i need to simply delare it once and use it on all asp pages? how are the asp pages related together as one application?for example, i have a page that displays records from a ms access database, all the ADODB connection keywords are inserted here, the user can add a new record, which is done in a another asp page. will i need to insert the ADODB connection keywords there too?anyone can help me out then great and thanks first

  4. ive got a customer table in MS Access and i just want to add a record to the table.  ive copied the example from insert example in thw website and modified it, every time i fill in the form ive created it says No update permissions, not sure why.  i do have primary key called customer_id.

    Did you manage to solve your problem. If you could help me I would be grateful. I'm having the same problem as you. I'm using MS access 2002 by the wayhere is my code:<%set conn=Server.CreateObject("ADODB.Connection")conn.Open "Forum"set rs=Server.CreateObject("ADODB.recordset")%><html><body><%sql="INSERT INTO forum1 (PosterName,Date,Comments,"sql=sql & " VALUES "sql=sql & "('" & Request.Form("name") & "',"sql=sql & "('" & Request.Form("date") & "',"sql=sql & "'" & Request.Form("comment") & "');"on error resume nextconn.Execute sql,recAffectedif err<>0 then Response.Write("No update permissions!")else Response.Write("<h3>" & recAffected & " record added</h3>")end ifconn.close%></body></html>
  5. I think it's possible your database itself doesn't give you permission to write.I suggest you do the following:1. right click on your database, select SECURITY and you should be seeing something like this INTERNET GUEST ACCOUNT (your-comp-name etc.)2. when you select it, check all the check boxes below in ALLOW column in order to gain those permissions..3. try to fill the form in again..NOTE: this is only one of the possible reasons..

    I'm having this same problem, I can't insert any records into my access database. I keep gertting referred to the no update permissions page alternative. I was wondering whether you could help me. Do you have any experience in using MS access 2002? here is my code:<%set conn=Server.CreateObject("ADODB.Connection")conn.Open "Forum"set rs=Server.CreateObject("ADODB.recordset")%><html><body><%sql="INSERT INTO forum1 (PosterName,Date,Comments,"sql=sql & " VALUES "sql=sql & "('" & Request.Form("name") & "',"sql=sql & "('" & Request.Form("date") & "',"sql=sql & "'" & Request.Form("comment") & "');"on error resume nextconn.Execute sql,recAffectedif err<>0 then Response.Write("No update permissions!")else Response.Write("<h3>" & recAffected & " record added</h3>")end ifconn.close%></body></html>
  6. You see, i think the problem might be in this:sql=sql & "'" & Request.Form("comment") & "')" (there is no ";" after closing bracket..Try insert it:sql=sql & "'" & Request.Form("comment") & "');"and let me know if that was the problem.

    Thanks for you reply. But it has not solved the problem. Having searched high and low around the world I am still not able to progress pass this dead lock which is sucking the life out of me!
  7. I'm having serious problems trying to insert data into a ms access database. everytime i submit the data, they don't get inserted into my ms access table. I think I don't have permission to insert data into the ms access table, but I don't know how to change the settings so that I can just simple insert data into my table. Any help as to the step-by-step procedure to solve my problem will be received with great thankshere's the code. the actual form part is from another asp page. This page does the actual inserting of data into table:<%set conn=Server.CreateObject("ADODB.Connection")conn.Open "Forum"set rs=Server.CreateObject("ADODB.recordset")%><html><body><%sql="INSERT INTO forum1 (PosterName,Date,Comments,"sql=sql & " VALUES "sql=sql & "('" & Request.Form("name") & "',"sql=sql & "('" & Request.Form("date") & "',"sql=sql & "'" & Request.Form("comment") & "')"on error resume nextconn.Execute sql,recaffectedif err<>0 then Response.Write("No update permissions!")else Response.Write("<h3>" & recaffected & " record added</h3>")end ifconn.close%></body></html>

×
×
  • Create New...