Problem inserting data to database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bseakgano
    New Member
    • Mar 2007
    • 12

    Problem inserting data to database

    I have developed a intranet . Using HTML , SQL and ASP . I have created a table with SQL is just fine . And design a form is just looks fine to me . But when I try to insert Data into the SQL I just have the Error . The Error appears when I press submit button . But when i just call it using this url http://10.164.1.86/lala.asp . It produce the massege i want it to produce after inserting the information. Hope you can help . My Code looks this one here .


    [HTML] <%

    Catergory = Trim(Request.Fo rm("registry") )
    If Catergory= "Title" then
    Title = Trim(Request.Fo rm("Title"))
    Author = Trim(Request.Fo rm("Author"))
    ISBN = Trim(Request.Fo rm("ISBN"))
    Publisher= Trim (Request.Form(" Publisher"))
    Place_of_Public ation= Trim(Request.Fo rm("Place of Publication"))
    Year=Trim(Reque st.Form("Year") )
    Collation=Trim( Request.Form("C ollation"))
    Shelf_Number=Tr im(Request.Form ("Shelf Number"))

    If Title <>"" and Author <>"" and ISBN <>"" and Publisher <>"" and Place_of_Public ation <>"" and Year <>"" and Collation <>"" and Shelf_Number<>" " Then

    %>

    MyStatement = "Insert into Book_files Set Values
    Title='"&Title& "',Author='"&Au thor&"', ISBN='"&ISBN&"' ,Publisher='"&P ublisher& "',Place_of_Pub lication='"& PlaceofPublicat ion&"',Year='"& Year&"',Collati on='"& Collation&"',Sh elf_Number='"&S helfNumber&"'"

    <%

    Set Con = Server.CreateOb ject("ADODB.Con ection")
    Con.Open "PROVIDER=SQLOL EDB;DATA SOURCE=master;U ID=sa;PWD=sa;DA TABASE=Book_fil es"

    Con.Execute MyStatement

    End IF
    End IF





    %>

    <Html>
    <Head><Title>In sert Data</Title></Head>
    <Body>
    <Form Method="POST" action.asp? /registry.html>< Head> <Center> <Font Color="Brown" Size=11 Face="Comic Sans Ms">
    Confirmation Page </Font> </Center>

    <Body BGColor="Yellow ">
    <Br><Br>

    <%


    Response.Write( " Your Value Has Been Successfully Inserted In The Table!")







    %>


    </Body>

    </Html>
    [/HTML]
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Your code looks OK to me. You get the satisfactory response when you just go to the web page because the db connection is within an if...then statement, so just browsing to that page skips that part of the code.

    What error are you getting? There might be a very simple explanation. I'm not sure it would help, but I'm willing to show you how I tend to code this, I write my insert lines a bit differently. I'm sure there's not a right way, but trying it differently couldn't hurt.

    Jared

    Comment

    • hini
      New Member
      • Mar 2007
      • 23

      #3
      What does this line mean ?
      Form Method="POST" action.asp? /registry.html

      Comment

      • bseakgano
        New Member
        • Mar 2007
        • 12

        #4
        Hello there

        When I execute it , Hoping it will show me that the result is inserted into the database , It just show the code of asp instead of confirmation massage . Like you values are inserted in the database . I had been trying this for a long time now . Can you Please try it and tell me it did work.

        Comment

        • bseakgano
          New Member
          • Mar 2007
          • 12

          #5
          When I execute it , Hoping it will show me that the result is inserted into the database , It just show the code of asp instead of confirmation massage . Like you values are inserted in the database . I had been trying this for a long time now . Can you Please try it and tell me it did work.

          Comment

          • bseakgano
            New Member
            • Mar 2007
            • 12

            #6
            This line is used to insert information into the database. It is used to call the parent registry with it. Or I use it to link the side.
            Form Method="POST" action.asp? /registry.html[/QUOTE]

            Comment

            • hini
              New Member
              • Mar 2007
              • 23

              #7
              this line is outside the script :

              MyStatement = "Insert into Book_files Set Values
              Title='"&Title& "',Author='"&Au thor&"', ISBN='"&ISBN&"' ,Publisher='"&P ublisher&"',Pla ce_of_Publicati on='"
              &PlaceofPublica tion&"',Year='" &Year&"',Collat ion='"&Collatio n&"',Shelf_Numb er='"&ShelfNumb er&"'"


              it must be inside the <% %> signs.

              Comment

              • jhardman
                Recognized Expert Specialist
                • Jan 2007
                • 3405

                #8
                Originally posted by hini
                What does this line mean ?
                Form Method="POST" action.asp? /registry.html
                Good catch, hini, I didn't even notice.

                The line should be more like:
                Code:
                <Form Method="POST" action="/registry.html">
                This could definitely be the problem. Although I'm not sure an HTML page will do anything to interpret the form data. What is the name of the page that handles the form?

                Jared

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Guys, let's make it a point to always wrap our code with code tags.

                  @OP Next time please try to choose a title that best describes your problem. I have just renamed your thread.

                  Comment

                  • bseakgano
                    New Member
                    • Mar 2007
                    • 12

                    #10
                    Can you please modify this code if possible . I have months now trying to insert data with this codes . When ever I try to execute this I get an error . I want to insert data into SQL with this codes . If I have skipped a line please let me know. I have tried to search from this site , hoping that someone had the same problems . but theirs was not responded . Now I don’t know what to do. Please help .







                    Code:
                     
                    <A Href="library.Html" Target="ThirdPartition"><Font Face="Garamond" Size="1">HOME</Font></A><br></br>
                     
                     
                     
                     
                    <html>
                     
                     
                    <Head> <U> <Center><Font Color="Red" Face="Garamond" Size=11> Registration Book</Font> </Center> </U>
                    <Title> Registration Page </Title>
                    </Head>
                    <Body Bgcolor="Pink">
                    <Form Method="Post" Action="lala.asp?">
                    <Br> <Br>
                    <B>Title:</B> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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="Title">
                    <Br> <Br>
                    <B>Author:</B>&nbsp;&nbsp;&nbsp;&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" Author="Author">
                    <Br> <Br>
                    <B>ISBN/ISSN	 :</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Input Type="Text" ISBN/ISSN="ISBN/ISSN">
                    <Br> <Br>
                    <B>Publisher:</B>&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="Publisher"><Br> <Br>
                    <B>Place Of Publication:</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Input Type="Text" Place Of Publication="Place Of Publication"><Br> <Br>
                    <B>Year:</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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" Year="Year">
                     
                    <br></br>
                    <B>Collation:</B>&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" Collation="Collation">
                     
                    <Br> <Br>
                    <B>Shelf Number	 :</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Input Type="Text" Shelf Number="Shelf Number">
                    <Br> <Br>
                     
                    <Br> <Br>
                    <Center><Input Type="Submit" Style="Font-Family:Monotype Corsiva;Color:Yellow;Font-Size:22;Font-Weight:Bold;Background:Brown" Value="Submit"></Center>
                    </Form>
                    </Body>
                    </Html>
                     
                     
                     
                     
                     
                     
                     
                     
                     
                     
                     
                     
                     
                     
                    <%
                    registry=Trim(Request.Form("registry"))
                    Catergory = Trim(Request.Form("registry"))
                    If Catergory= "Title" then
                    Title = Trim(Request.Form("Title"))
                    Author = Trim(Request.Form("Author"))
                    ISBN = Trim(Request.Form("ISBN"))
                    Publisher= Trim (Request.Form("Publisher"))
                    Place_of_Publication= Trim(Request.Form("Place of Publication"))
                    Year=Trim(Request.Form("Year"))
                    Collation=Trim(Request.Form("Collation"))
                    Shelf_Number=Trim(Request.Form("Shelf Number"))
                     
                    If Title <>"" and Author <>"" and ISBN <>"" and Publisher <>"" and Place_of_Publication <>"" and Year <>"" and Collation <>"" and Shelf_Number<>"" Then
                     
                     
                    <%
                     
                    MyStatement = "Insert into Book_files Set Values
                    Title='"&Title&"',Author='"&Author&"', ISBN='"&ISBN&"',Publisher='"&Publisher&"',Place_of_Publication='"& PlaceofPublication&"',Year='"&Year&"',Collation='"&Collation &"',Shelf_Number='"&ShelfNumber&"'" 
                    Set Con = Server.CreateObject("SQLOLEDB")
                    Con.Open "PROVIDER=SQLOLEDB;DATA SOURCE=master;UID=<hidden>;PWD=<hidden>;DATABASE=Book_files"
                     
                    Con.Execute MyStatement
                     
                    End IF
                    End IF
                     
                     
                     
                     
                     
                    %>
                     
                    <Html>
                    <Head><Title>Insert Data</Title></Head>
                    <Body>
                     
                    <Form Method="POST" action="/registry.html"><Head> <Center> <Font Color="Brown" Size=11 Face="Comic Sans Ms"> 
                    Confirmation Page </Font> </Center>
                     
                    <Body BGColor="Yellow">
                    <Br><Br>
                     
                    <%
                     
                     
                    Response.Write(" Your Value Has Been Successfully Inserted In The Table!")
                     
                     
                     
                     
                    End IF
                     
                     
                    %>
                     
                     
                    </Body>
                     
                    </Html>
                    Edited Code - Removed username and password for database from his code (also wrapped it in code tags) - iam_clint

                    Comment

                    • jhardman
                      Recognized Expert Specialist
                      • Jan 2007
                      • 3405

                      #11
                      Alright, bseakgano. I will help you, but you must trust me and do what I say. Understand?

                      First off, there are several mistakes in your form. you can't name a tag attribute like this:
                      Code:
                      <Input Type="Text" ISBN/ISSN="ISBN/ISSN">
                      and then get the data like this:
                      Code:
                      ISBN = Trim(Request.Form("ISBN"))
                      instead it should read:
                      Code:
                      <Input Type="Text" name="ISBN">
                      in other words, each input tag should have a name attribute which tells the name of the input, then you access that input according to the name attribute:
                      Code:
                      ISBN = Trim(Request.Form("ISBN"))
                      You were very sloppy not using the same name you had chosen when you tried to access the input data. First, fix all of the form input names.

                      Second, make sure you are getting all of the input data you expect by listing them severally right before you need to use them:
                      Code:
                      response.write "Author: " & request.form("author") & "<br>" & vbNewLine
                      'etc
                      This verifies that the data was passed to the script that will handle it in the way you expect it.

                      Third, your insert code is all within a complex if...then statement wherein if a single input is blank or mis-named the entire thing will not execute and the entered data will be lost. Unless you fix everything else, the database will never be updated. Besides that, it is very difficult for us as anonymous people on a forum to fix data base access on someone else's server. In order for your code to work on our servers, we would need a database set up identically to yours, so it is going to be difficult for us to even check.

                      Fourth, please fix your HTML code. Running your page through an HTML validator (see the sticky at the top of the HTML forum) would have caught several of these errors. Formatting your pages with css or even placing your inputs within a table would have aligned them better and made reading through the code easier. It is very difficult to read through someone's code where half of the code is
                      Code:
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      &nbsp;&nbsp;&nbsp;&nbsp;
                      I have connected to different types of databases and updated databases in different ways and using different methods. If you fix those problems and post your corrected code I will help you in the next step. Oh, and post your code within code tags (the word "code" in square brackets to start, and "/code" in square brackets to finish).

                      Jared

                      Comment

                      • bseakgano
                        New Member
                        • Mar 2007
                        • 12

                        #12
                        I still have a problem . Now I do understand that what I am doing is not easy like I thought . Please you may do something like what I did . All I want is light . I will follow . Please believe me I have tried everything from you guys I still have the code. The worst part now is when I try to execute it turn itself into a search engine. Guys please I need you help. This my code after I try to fix something in it. But it become worse . My wish to help others with same problem in the future .
                        [code=html]
                        <html>

                        <Head> <U> <Center><Font Color="Red" Face="Garamond" Size=11> Registration Book</Font> </Center> </U>
                        <Title> Registration Page </Title>
                        </Head>
                        <Body Bgcolor="Pink">
                        <code> <Form Method="Post" Action="lala.as p?"> </code>
                        <Br> <Br>
                        <B>Title :</B> &nbsp;&nbsp;<In put Type="Text" Name="Title">
                        <Br> <Br>
                        <B>Author :</B>&nbsp;&nbsp;& nbsp;<Input Type="Text" Author="Author" >
                        <Br> <Br>
                        <B>ISBN :</B>&nbsp;&nbsp;& nbsp;<Input Type="Text" ISBN/ISSN="ISBN">
                        <Br> <Br>
                        <B>Publisher: </B>&nbsp;&nbsp;& nbsp;&nbsp;&nbs p;&nbsp<Input Type="Text" Name="Publisher "><Br> <Br>
                        <B>Place Of Publication:</B>&nbsp;&nbsp;& nbsp;&nbsp;&nbs p;<Input Type="Text" Place Of Publication="Pl ace Of Publication"><B r> <Br>
                        <B>Year: </B>&nbsp;&nbsp;& nbsp;&nbsp;<Inp ut Type="Text" Year="Year">

                        <br></br>
                        <B>Collation :</B>&nbsp;&nbsp;& nbsp;&nbsp;&nbs p;&nbsp;&nbsp;& nbsp;<Input Type="Text" Collation="Coll ation">

                        <Br> <Br>
                        <B>Shelf Number :</B>&nbsp;&nbsp;& nbsp;&nbsp;&nbs p;&nbsp;&nbsp;& nbsp;<Input Type="Text" Shelf Number="Shelf Number">
                        <Br> <Br>

                        <Br> <Br>
                        <Center><Inpu t Type="Submit" Style="Font-Family:Monotype Corsiva;Color:Y ellow;Font-Size:22;Font-Weight:Bold;Bac kground:Brown" Value="Submit"> </Center>
                        </Form>
                        </Body>
                        </Html>[/code]
                        ASP CODE
                        [code=asp]
                        <%
                        category = Trim(Request.Fo rm("registry") )
                        If category="Book_ files" then
                        Title = Trim(Request.Fo rm("Title"))
                        Author = Trim(Request.Fo rm("Author"))
                        ISBN = Trim(Request.Fo rm("ISBN"))
                        Publisher = Trim(Request.Fo rm("Publisher") )
                        Place_of_Public ation = Trim(Request.Fo rm("PlaceofPubl ication"))
                        Year = Trim(Request.Fo rm("Year"))
                        Collation = Trim(Request.Fo rm("Collation") )
                        Shelf Number = Trim(Request.Fo rm("ShelfNumber "))
                        If CBookTitle<>"" AND CAuthor<>"" AND IISBN<>"" AND CPublisher<>""A ND CPlaceofPublica tion<>"" AND IYear<>"" AND CCollation<>"" AND IShelfNu<>"" Then
                        MySQL = "Insert into Book_files(CBoo k_Titles,CAutho r,IISBN,CPublis her,CPlace_of_P ublication,
                        IYear,CCollatio n,IShelfNu
                        Values('"&BookT itle&"','"&Auth or&"','"&ISBN&" ','"Publisher&" ','"&PlaceofPub lication&"',
                        '"&Year&"','"&C ollation&"','"& ShelfNu&"')"
                        Set con = Server.CreateOb ject("ADODB.Con nection")
                        Con.Open "Provider=SQLOL EDB;Data Source=G144379\ G144379;UID=sa; Pwd=sa;DataBase =Bruno;

                        response.write "Title: " & request.form("T itle") & "<br>" & vbNewLine
                        ',"Author: " & request.form("a uthor") & "<br>" & vbNewLine
                        ',"ISBN: " & request.form("I SBN") & "<br>" & vbNewLine
                        ',"Publisher: " & request.form("P ublisher") & "<br>" & vbNewLine
                        ',"Place of Publication: " & request.form("P lace of Publication") & "<br>" & vbNewLine
                        ',"Year: " & request.form("Y ear") & "<br>" & vbNewLine
                        ',"Collation: " & request.form("C ollation") & "<br>" & vbNewLine
                        ',"Shelf Number: " & request.form("S helf Number") & "<br>" & vbNewLine

                        Con.Execute MySQL
                        end if



                        %>
                        <Html>
                        <Head> <Center> <Font Color="Brown" Size=11 Face="Comic Sans Ms">
                        Confirmation Page </Font> </Center>
                        <Title> Results Returned By Active Server Pages </Title>
                        </Head>
                        <Body BGColor="Yellow ">
                        <Br><Br>


                        <%

                        Response.Write ("Your Value Has Been Successfully Inserted In The Table!")
                        End If


                        %>


                        </Body>
                        </Html>[/code]




                        SQL is Like This
                        [code=sql]
                        Create table Book_file
                        (
                        Title char(100)not null,
                        Author char(100)not null,
                        ISBN into,
                        Publisher char(100),
                        Place_of_Publis her char(100),
                        Year into,
                        Collation varchar(100),
                        Shelf_number int
                        )[/code]
                        Last edited by jhardman; Mar 27 '08, 02:09 AM. Reason: put code in code tags. Please note button marked - #

                        Comment

                        • jhardman
                          Recognized Expert Specialist
                          • Jan 2007
                          • 3405

                          #13
                          try this exact code. Don't change a thing:
                          Code:
                          <%
                          if request.form("title") = "" then %>
                          	<html>
                          		<Head>
                          			<Title>Registration Page</Title>
                          			<style>
                          				<!--
                          
                          				label {
                          					color: black;
                          					position: relative;
                          					left: 40px;
                          				}
                          
                          				input {
                          					position: absolute;
                          					top: inherit;
                          					left: 220px;
                          				}
                          
                          				fieldset {
                          					border: 0px;
                          					padding: 5px;
                          				}
                          
                          				-->
                          			</style>
                          		</head>
                          		<body style="background-color: pink">
                          			<h1 style="text-align: center; text-decoration: underline;font:Garamond 
                          			san-serif 16pt;color:'Red'"> Registration Book</h1>
                          			<Form Method="Post" Action="lala.asp">
                          				<fieldset><label for="title">Title:</label><input type="text" 
                          				name="title" value="<%=request.form("title")%>"></fieldset>
                          				<fieldset><label for="author">Author:</label><Input type="text" 
                          				name="author" value="<%=request.form("author")%>"></fieldset>
                          				<fieldset><label for="isbn">ISBN/ISSN:</label><Input type="text"
                          				 name="isbn" value="<%=request.form("isbn")%>"></fieldset>
                          				<fieldset><label for="publisher">Publisher:</label><Input type="text"
                          				 name="publisher" value="<%=request.form("publisher")%>"></fieldset>
                          				<fieldset><label for="place">Place of Publication:</label><Input
                          				 type="text" name="place" value="<%=request.form("place")%>"></fieldset>
                          				<fieldset><label for="year">Year:</label><Input type="text" 
                          				name="year" value="<%=request.form("year")%>"></fieldset>
                          				<fieldset><label for="collation">Collation:</label><Input
                          				 type="text" value="<%=request.form("collation")%>" name="collation"></fieldset>
                          				<fieldset><label for="shelf">Shelf Number:</label><Input
                          				 type="text" name="shelf" value="<%=request.form("shelf")%>"></fieldset>
                          				<fieldset style="text-align: center"><Input type="submit"
                          				 style="Font-Family:Monotype Corsiva;
                          					Color:Yellow;Font-Size:22;Font-Weight:Bold;Background:Brown"
                          				 Value="Submit"></fieldset>
                          				
                          			</Form>
                          		</Body>
                          	</Html>
                          
                          <%
                          else
                          	'category = Trim(Request.Form("registry"))
                          	'If category="Book_files" then
                          		dim fld, inp, objCon, objRS
                          		for each inp in request.form
                          			response.write inp & ": " & request.form(inp) & "<br>" & vbNewLine
                          		next
                          
                          		'Title = Trim(Request.Form("Title"))
                          		'Author = Trim(Request.Form("Author"))
                          		'ISBN = Trim(Request.Form("ISBN"))
                          		'Publisher = Trim(Request.Form("Publisher"))
                          		'Place_of_Publication = Trim(Request.Form("PlaceofPublication"))
                          		'Year = Trim(Request.Form("Year"))
                          		'Collation = Trim(Request.Form("Collation"))
                          		'Shelf Number = Trim(Request.Form("ShelfNumber"))
                          		'If CBookTitle<>"" AND CAuthor<>"" AND IISBN<>"" AND CPublisher<>""AND CPlaceofPublication<>"" AND IYear<>"" AND CCollation<>"" AND IShelfNu<>"" Then
                          		'MySQL = "Insert into Book_files(CBook_Titles,CAuthor,IISBN,CPublisher,C Place_of_Publication,IYear,CCollation,IShelfNu
                          		'Values('"&BookTitle&"','"&Author&"','"&ISBN&"','"Publisher&"','"& PlaceofPublication&"','"&Year&"','"&Collation&"','"&ShelfNu&"')"
                          		Set objCon = Server.CreateObject("ADODB.Connection")
                          		objCon.Open "Provider=SQLOLEDB;Data Source=G144379\G144379;UID=sa;Pwd=sa;DataBase=Brun o;
                          		set objRS = Server.CreateObject("ADODB.Recordset")
                          		objRS.open "SELECT * FROM [Book_files]", objCon
                          
                          		for each fld in objRS.fields
                          			response.write fld.name & "<br>" & vbNewLine
                          		next
                          
                          		'response.write "Title: " & request.form("Title") & "<br>" & vbNewLine
                          		',"Author: " & request.form("author") & "<br>" & vbNewLine
                          		',"ISBN: " & request.form("ISBN") & "<br>" & vbNewLine
                          		',"Publisher: " & request.form("Publisher") & "<br>" & vbNewLine
                          		',"Place of Publication: " & request.form("Place of Publication") & "<br>" & vbNewLine
                          		',"Year: " & request.form("Year") & "<br>" & vbNewLine
                          		',"Collation: " & request.form("Collation") & "<br>" & vbNewLine
                          		',"Shelf Number: " & request.form("Shelf Number") & "<br>" & vbNewLine
                          
                          		'Con.Execute MySQL
                          	'end if %>
                          
                          	<Html>
                          	<Head> <Center> <Font Color="Brown" Size=11 Face="Comic Sans Ms">
                          	Confirmation Page </Font> </Center>
                          	<Title> Results Returned By Active Server Pages </Title>
                          	</Head>
                          	<Body BGColor="Yellow">
                          	<Br><Br>
                          	<%
                          
                          	'Response.Write ("Your Value Has Been Successfully Inserted In The Table!")
                          End If %>
                          
                          </Body>
                          </Html>
                          
                          <!--
                          
                          SQL is Like This
                          
                          Create table Book_file
                          (
                          Title char(100)not null,
                          Author char(100)not null,
                          ISBN into,
                          Publisher char(100),
                          Place_of_Publisher char(100),
                          Year into,
                          Collation varchar(100),
                          Shelf_number int
                          )
                          -->
                          Save the entire thing as one file named lala.asp. Run it and let me know what happened

                          Comment

                          • bseakgano
                            New Member
                            • Mar 2007
                            • 12

                            #14
                            Now I see things i don't understand. Or is it because i might be kicked out. I don't know. Though i last did coding by the year 2002. I was unemployed until few weeks back. To do some project but now is hard to code it down.

                            Though back to the ASP now. When i copy and paste the whole code. It fail to open but when i take Html alone ,it desplays A mixer . I mean at Title i get something like this ">Title and at Author is like this Au">thor. But this on top of u.It shows a mixed up of codes and signs. Some and when i open ASP alone It take me to the internat . But but now i don't now. I traed to check the errors. wright now I realy don't or is it IIS, becouse separetly you code gives me the same errors which i was complaining about. except this small things. I am using the Win XP. I have learnt ASP on Win1998, Where by you will go to Start-Program-Winndows NT 4.0 option pack-Microsoft Inter Infor-Inter Serv Manage.

                            But this one i just went to Add programme and select IIS . thogh others are working. The small codes. Only this long is something else.

                            Comment

                            • jhardman
                              Recognized Expert Specialist
                              • Jan 2007
                              • 3405

                              #15
                              OK, try this variation. I put it up on one of my development sites, but the domain registration just ran out...

                              Jared
                              Code:
                              <%
                              if request.form("title") = "" then %>
                              	<html>
                              		<Head>
                              			<Title>Registration Page</Title>
                              			<style>
                              				<!--
                              
                              				label {
                              					color: black;
                              					position: relative;
                              					left: 40px;
                              				}
                              
                              				input {
                              					position: absolute;
                              					top: inherit;
                              					left: 220px;
                              				}
                              
                              				fieldset {
                              					border: 0px;
                              					padding: 5px;
                              				}
                              
                              				-->
                              			</style>
                              		</head>
                              		<body style="background-color: pink">
                              			<h1 style="text-align: center; text-decoration: underline;font:Garamond 
                              			san-serif 16pt;color:'Red'"> Registration Book</h1>
                              			<Form Method="Post" Action="lala.asp">
                              				<fieldset><label for="title">Title:</label><input type="text" 
                              				name="title" value="<%=request.form("title")%>"></fieldset>
                              				<fieldset><label for="author">Author:</label><Input type="text" 
                              				name="author" value="<%=request.form("author")%>"></fieldset>
                              				<fieldset><label for="isbn">ISBN/ISSN:</label><Input type="text"
                              				 name="isbn" value="<%=request.form("isbn")%>"></fieldset>
                              				<fieldset><label for="publisher">Publisher:</label><Input type="text"
                              				 name="publisher" value="<%=request.form("publisher")%>"></fieldset>
                              				<fieldset><label for="place">Place of Publication:</label><Input
                              				 type="text" name="place" value="<%=request.form("place")%>"></fieldset>
                              				<fieldset><label for="year">Year:</label><Input type="text" 
                              				name="year" value="<%=request.form("year")%>"></fieldset>
                              				<fieldset><label for="collation">Collation:</label><Input
                              				 type="text" value="<%=request.form("collation")%>" name="collation"></fieldset>
                              				<fieldset><label for="shelf">Shelf Number:</label><Input
                              				 type="text" name="shelf" value="<%=request.form("shelf")%>"></fieldset>
                              				<fieldset style="text-align: center"><Input type="submit"
                              				 style="Font-Family:Monotype Corsiva;
                              					Color:Yellow;Font-Size:22;Font-Weight:Bold;Background:Brown"
                              				 Value="Submit"></fieldset>
                              				
                              			</Form>
                              		</Body>
                              	</Html>
                              
                              <%
                              else
                              	'category = Trim(Request.Form("registry"))
                              	'If category="Book_files" then
                              		dim fld, inp, objCon, objRS
                              		for each inp in request.form
                              			response.write inp & ": " & request.form(inp) & "<br>" & vbNewLine
                              		next
                              
                              		'Title = Trim(Request.Form("Title"))
                              		'Author = Trim(Request.Form("Author"))
                              		'ISBN = Trim(Request.Form("ISBN"))
                              		'Publisher = Trim(Request.Form("Publisher"))
                              		'Place_of_Publication = Trim(Request.Form("PlaceofPublication"))
                              		'Year = Trim(Request.Form("Year"))
                              		'Collation = Trim(Request.Form("Collation"))
                              		'Shelf Number = Trim(Request.Form("ShelfNumber"))
                              		'If CBookTitle<>"" AND CAuthor<>"" AND IISBN<>"" AND CPublisher<>""AND CPlaceofPublication<>"" AND IYear<>"" AND CCollation<>"" AND IShelfNu<>"" Then
                              		'MySQL = "Insert into Book_files(CBook_Titles,CAuthor,IISBN,CPublisher,C Place_of_Publication,IYear,CCollation,IShelfNu
                              		'Values('"&BookTitle&"', '"&Author&"', '"&ISBN&"', '"Publisher&"', '"&PlaceofPublication&"', '"&Year&"', '"&Collation&"', '"&ShelfNu&"')"
                              		'Set objCon = Server.CreateObject("ADODB.Connection")
                              		'objCon.Open "Provider=SQLOLEDB;Data Source=G144379\G144379;UID=sa;Pwd=sa;DataBase=Brun o;
                              		'set objRS = Server.CreateObject("ADODB.Recordset")
                              		'objRS.open "SELECT * FROM [Book_files]", objCon
                              
                              		'for each fld in objRS.fields
                              		'	response.write fld.name & "<br>" & vbNewLine
                              		'next
                              
                              		'response.write "Title: " & request.form("Title") & "<br>" & vbNewLine
                              		',"Author: " & request.form("author") & "<br>" & vbNewLine
                              		',"ISBN: " & request.form("ISBN") & "<br>" & vbNewLine
                              		',"Publisher: " & request.form("Publisher") & "<br>" & vbNewLine
                              		',"Place of Publication: " & request.form("Place of Publication") & "<br>" & vbNewLine
                              		',"Year: " & request.form("Year") & "<br>" & vbNewLine
                              		',"Collation: " & request.form("Collation") & "<br>" & vbNewLine
                              		',"Shelf Number: " & request.form("Shelf Number") & "<br>" & vbNewLine
                              
                              		'Con.Execute MySQL
                              	'end if %>
                              
                              	<Html>
                              	<Head> <Center> <Font Color="Brown" Size=11 Face="Comic Sans Ms">
                              	Confirmation Page </Font> </Center>
                              	<Title> Results Returned By Active Server Pages </Title>
                              	</Head>
                              	<Body BGColor="Yellow">
                              	<Br><Br>
                              	<%
                              
                              	'Response.Write ("Your Value Has Been Successfully Inserted In The Table!")
                              End If %>
                              
                              </Body>
                              </Html>
                              
                              <!--
                              
                              SQL is Like This
                              
                              Create table Book_file
                              (
                              Title char(100)not null,
                              Author char(100)not null,
                              ISBN into,
                              Publisher char(100),
                              Place_of_Publisher char(100),
                              Year into,
                              Collation varchar(100),
                              Shelf_number int
                              )
                              -->

                              Comment

                              Working...