48 users online (0 members and 48 guests)  


Page 1 of 2 1 2 Last
  Results 1 to 15 of 25

Related

  1. HTML table to Database    Forum: HTML Forum
    Replies: 2
  2. Script database 29,000 Records for sale    Forum: Websites For Sale
    Replies: 1
  1. #1
    nawaray's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    14

    inseting records to a database through html code...

    hi,,, i have this html page that consists of fields name,tel,etc...
    i want when the user fills the fields and presses submit the data will be stored in the database,,,
    the database is stored in this path:C:\Documents and Settings\NooraS\My
    Documents\noora\Ammar\myweb71")_
    i wrote this code but it doesn't store the data , any help:
    HTML Code:
    <% 
    set myconn = server.createobject("adodb.connection")
    dbpath = server.mappath("C:\Documents and Settings\NooraS\My 
    Documents\noora\Ammar\myweb71")
    connection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & dbpath & "\Ammar.mdb"
    myconn.open (connection)
    set result = server.createobject("adodb.recordset")
    set result = myconn.execute(strSQL )
     
    %>
    this is my whole page code:
    HTML Code:
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta http-equiv="Content-Language" content="en-us">
    <title>ares Product 1</title>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <!--mstheme--><link rel="stylesheet" type="text/css" 
    href="_themes/global/glob1111.css"><meta name="Microsoft Theme" content="global 1111, 
    default">
    <meta name="Microsoft Border" content="tlb, default">
    </head>
    <body  ><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" 
    width="100%"><tr><td>
     
     
    
    <% 
    set myconn = server.createobject("adodb.connection")
    dbpath = server.mappath("C:\Documents and Settings\NooraS\My Documents\noora\Ammar")
    connection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & dbpath & "\Ammar.mdb"
    myconn.open (connection)
    set result = server.createobject("adodb.recordset")
    set result = myconn.execute(strSQL )
    
    %>
     
     
    <p>
    <a href="index.htm">Home</a></p>
    <p>
    <img src="_derived/prod01.htm_cmp_global110_bnr.gif" width="600" height="60" border="0" 
    alt="Buy">
    <br>
    <img src="_derived/prod01.htm_cmp_global110_hbtn_p.gif" width="140" height="50" border="0" 
    alt="Buy" align="middle"> <script language="JavaScript"><!--
    MSFPhover = 
      (((navigator.appName == "Netscape") && 
      (parseInt(navigator.appVersion) >= 3 )) || 
      ((navigator.appName == "Microsoft Internet Explorer") && 
      (parseInt(navigator.appVersion) >= 4 ))); 
    function MSFPpreload(img) 
    {
      var a=new Image(); a.src=img; return a; 
    }
    // --></script><script language="JavaScript"><!--
    if(MSFPhover) { MSFPnav1n=MSFPpreload
    ("_derived/new_page_1.htm_cmp_global110_hbtn.gif"); MSFPnav1h=MSFPpreload
    ("_derived/new_page_1.htm_cmp_global110_hbtn_a.gif"); }
    // --></script><a 
    href="new_page_1.htm" language="JavaScript" onmouseover="if(MSFPhover) document
    ['MSFPnav1'].src=MSFPnav1h.src" onmouseout="if(MSFPhover) document
    ['MSFPnav1'].src=MSFPnav1n.src"><img src="_derived/new_page_1.htm_cmp_global110_hbtn.gif" 
    width="140" height="50" border="0" alt="Sell" align="middle" name="MSFPnav1"></a>
    </p>
    
    <p>&nbsp;</p>
    </td></tr><!--msnavigation--></table><!--msnavigation--><table dir="ltr" border="0" 
    cellpadding="0" cellspacing="0" width="100%"><tr><td valign="top" width="1%">
    
    <p>&nbsp;</p>
    
    <p>
    </p>
    </td><td valign="top" width="24"></td><!--msnavigation--><td valign="top">
    <p>Please fill out the following form in order to process your order.</p>
    <p>Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="text" name="T1" size="20"></p>
    <p>Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
    sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="text" name="T1" size="20"></p>
    <p>Tel / 
    Mobile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
    nbsp;
    <input type="text" name="T1" size="20"></p>
    <p>Product description&nbsp;&nbsp; <input type="text" name="T1" size="20"></p>
    <p>Credit card number&nbsp;&nbsp; <input type="text" name="T1" size="20"></p>
    <p align="center"><b><a href="toppage1.htm">Submit</a></b></p>
    <!--msnavigation--></td></tr><!--msnavigation--></table><!--msnavigation--><table 
    border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>
    <p>&nbsp;</p>
     
    <h5>
    Send mail to <a href="mailto:webmaster@eshopping.com">
    webmaster@eshopping.com</a> with
    questions or comments about this web site.<br>
    
    Copyright  2007 AR e-shopping<br>
    
    Last modified: 
    03/02/07
    </h5>
    </td></tr><!--msnavigation--></table></body>
    </html>
    any help

  2. #2
    nawaray's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    14

    Re: inseting records to a database through html code...

    sorry this is the correct code
    HTML Code:
    <% 
    dim strSQL
    set myconn = server.createobject("adodb.connection")
    set dbpath = server.mappath("C:\Documents and Settings\NooraS\My Documents\noora\Ammar")
    connection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & dbpath & "\Ammar.mdb"
    myconn.open (connection)
    set result = server.createobject("adodb.recordset")
    set result = myconn.execute(strSQL )
     
    strSQL = "INSERT INTO [Buy_info](name, address,Tel/Mobile, Product description, Credit card number) Values ('" &name & "' , '" & address & "' , '" & tel & "' , '" & products_des & "' , '" & cc_no & "' )"
    myconn.execute(strSQL)
    %>
    Last edited by nawaray; 04-04-2007 at 05:47 AM.

  3. #3
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: inseting records to a database through html code...

    There are a couple of possible problems that I see with your SQL statement. In Microsoft Access, I don't believe you can have brackets around your table name. I'm not entirely sure about that but try the query without those brackets. Secondly, on that SQL statement you have:

    Code:
    ('" &name & "' ,
    Change that to:

    Code:
    ('" & name & "' ,
    If the above doesn't fix the problem, another thing you might try is adding the following after your SQL statement:

    Code:
    Response.Write strSQL
    Response.End
    Unless you can spot the problem directly with your SQL statement, copy the display into a query window within Microsoft Access and run the query from there. Does it work? Do you get an error message?
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  4. #4
    nawaray's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    14

    Re: inseting records to a database through html code...

    hi,,,
    i tried what you said but still i don't get the records stored in the database
    is my code correct?

  5. #5
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: inseting records to a database through html code...

    Did you do the second half of my suggestion, which was to display the query from your code, copy the query and try to run it through Microsoft Access? BTW, what does that displayed query look like?
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  6. #6
    nawaray's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    14

    Re: inseting records to a database through html code...

    yes i tied the second part i still didn;t work, ok this is what i want how can i do this,,,

    if i have a database stored in an A:\ drive say for example test , and i have the html pages stored there to, if one of the html pages contains fields that i should fill in like (name, address, etc) and then when i press the submit button the record should be stored in the database , how can i write this code?

  7. #7
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: inseting records to a database through html code...

    OK, but you didn't answer this question:

    BTW, what does that displayed query look like?
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  8. #8
    nawaray's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    14

    Re: inseting records to a database through html code...

    i don't understand what you mean?
    my form consists of fields that should be filled and then when i click on submit it should be saved in the table

  9. #9
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: inseting records to a database through html code...

    I suspect the problem is with your query. That's why I want to see what the query looks like. This is just a means of debugging your code, trying to find out what's wrong. So, I repeat - What does your displayed query look like?
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  10. #10
    nawaray's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    14

    Re: inseting records to a database through html code...

    this is my code...
    as i said before that when i press the submit button i don't grt any error , this is my insert query:
    HTML Code:
    strSQL = "INSERT INTO [Buy_info](name, address,Tel/Mobile, Product description, Credit card number) Values ('" &name & "' , '" & address & "' , '" & tel & "' , '" & products_des & "' , '" & cc_no & "' )"

    <FONT color=#000080>
    HTML Code:
    dim strSQL
    set myconn = server.createobject("adodb.connection")
    set dbpath = server.mappath("C:\Documents and Settings\NooraS\My Documents\noora\Ammar")
    connection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & dbpath & "\Ammar.mdb"
    myconn.open (connection)
    set result = server.createobject("adodb.recordset")
    set result = myconn.execute(strSQL )
     
    strSQL = "INSERT INTO [Buy_info](name, address,Tel/Mobile, Product description, Credit card number) Values ('" &name & "' , '" & address & "' , '" & tel & "' , '" & products_des & "' , '" & cc_no & "' )"
    myconn.execute(strSQL)
    %>

  11. #11
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: inseting records to a database through html code...

    Change your code to the following. Run it. Tell me what is displayed.

    Code:
    dim strSQL
    set myconn = server.createobject("adodb.connection")
    set dbpath = server.mappath("C:\Documents and Settings\NooraS\My Documents\noora\Ammar")
    connection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & dbpath & "\Ammar.mdb"
    myconn.open (connection)
    set result = server.createobject("adodb.recordset")
    set result = myconn.execute(strSQL )
     
    strSQL = "INSERT INTO [Buy_info](name, address,Tel/Mobile, Product description, Credit card number) Values ('" &name & "' , '" & address & "' , '" & tel & "' , '" & products_des & "' , '" & cc_no & "' )"
    Response.Write strSQL
    Response.End
    myconn.execute(strSQL)
    %>
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  12. #12
    nawaray's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    14

    Re: inseting records to a database through html code...

    hi ,,,, i copied and pasted what you told me and i did not get anythig , when i pressed the submit button nothing appeared it took me to the home page

  13. #13
    nawaray's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    14

    Re: inseting records to a database through html code...

    and is this correct the way i define the connection even if i'm not connect to the server , i mean my folder is saved in disk?
    HTML Code:
    dim strSQL
    set myconn = server.createobject("adodb.connection")
    set dbpath = server.mappath("C:\Documents and Settings\NooraS\My Documents\noora\Ammar")
    connection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & dbpath & "\Ammar.mdb"

  14. #14
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: inseting records to a database through html code...

    OK, I'm pretty sure I've figured out what you need. You defined the variable called result twice, essentially overlaying the correct definition with the incorrect definition, here:

    Code:
    set result = server.createobject("adodb.recordset")
    set result = myconn.execute(strSQL )
    Get rid of that second line of code.

    Secondly, you're not executing your query string correctly. Change this:

    Code:
    myconn.execute(strSQL)
    to this:

    Code:
    result.open strSQL, myconn
    So the complete code you end up with is this (my apologies for rearranging some things. It was the only way I could compare it to some code I had done on my own application):

    Code:
    <% 
    dim strSQL
    strSQL = "INSERT INTO [Buy_info](name, address,Tel/Mobile, Product description, Credit card number) Values ('" &name & "' , '" & address & "' , '" & tel & "' , '" & products_des & "' , '" & cc_no & "' )"
    set dbpath = server.mappath("C:\Documents and Settings\NooraS\My Documents\noora\Ammar")
    set connection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & dbpath & "\Ammar.mdb"
    set myconn = server.createobject("adodb.connection")
    myconn.open connection
    set result = server.createobject("adodb.recordset")
    result.open strSQL, myconn
    %>
    Getting back to your query definition (and a comment from one of my previous posts), if this doesn't work, remove the brackets from around your table name, like so:

    Code:
    strSQL = "INSERT INTO Buy_info (name, address,Tel/Mobile, Product description, Credit card number) Values ('" &name & "' , '" & address & "' , '" & tel & "' , '" & products_des & "' , '" & cc_no & "' )"
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  15. #15
    nawaray's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    14

    Re: inseting records to a database through html code...

    hi,,, this is my final code i wrote ...
    HTML Code:
    <%
    dim conn
    set conn=Server.CreateObject("ADODB.Connection")
    conn.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=C:\\Ammar.mdb"  'this is without a password
    set rs=Server.CreateObject("ADODB.command")
    strsql = "INSERT INTO [Buy_info](name, address, tel , products_ des,cc_no) Values('" + Request("name") + "' , '" + Request("address") + "' , '" + Request(" tel") + "' , '" + Request("products_des ")+ "' , '" + Request("cc_no")+ "')"
    'strsql="update Buy_info set name='" + request("name")+"' , address='" +request("address") +"' , tel='" +  request("tel")+ "', products_des='"+  request("products_des")+"' , email='" +request("email") +"' , cc_no='"+ request("cc_no")+"' " 
    conn.execute(strsql)
    
    %>
    and i get this error:
    Script error detected at line 14.
    Source line: conn.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=C:\\Ammar.mdb" 'this is without a password
    Description: Unrecognized database format 'C:\Ammar.mdb'.
    and my database is in the c drive with the given name Ammar, where is the error?



Page 1 of 2 1 2 Last

Tags for this Thread