472,351 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,351 software developers and data experts.

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.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("ADODB.Conection")
Con.Open "PROVIDER=SQLOLEDB;DATA SOURCE=master;UID=sa;PWD=sa;DATABASE=Book_files"

Con.Execute MyStatement

End IF
End IF





%>

<Html>
<Head><Title>Insert 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]
Mar 8 '07 #1
25 2849
jhardman
3,406 Expert 2GB
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
Mar 8 '07 #2
hini
23
What does this line mean ?
Form Method="POST" action.asp? /registry.html
Mar 9 '07 #3
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.
Mar 9 '07 #4
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.
Mar 9 '07 #5
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]
Mar 9 '07 #6
hini
23
this line is outside the script :

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&"'"


it must be inside the <% %> signs.
Mar 9 '07 #7
jhardman
3,406 Expert 2GB
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:
Expand|Select|Wrap|Line Numbers
  1. <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
Mar 9 '07 #8
r035198x
13,262 8TB
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.
Mar 10 '07 #9
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 .







Expand|Select|Wrap|Line Numbers
  1.  
  2. <A Href="library.Html" Target="ThirdPartition"><Font Face="Garamond" Size="1">HOME</Font></A><br></br>
  3.  
  4.  
  5.  
  6.  
  7. <html>
  8.  
  9.  
  10. <Head> <U> <Center><Font Color="Red" Face="Garamond" Size=11> Registration Book</Font> </Center> </U>
  11. <Title> Registration Page </Title>
  12. </Head>
  13. <Body Bgcolor="Pink">
  14. <Form Method="Post" Action="lala.asp?">
  15. <Br> <Br>
  16. <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">
  17. <Br> <Br>
  18. <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">
  19. <Br> <Br>
  20. <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">
  21. <Br> <Br>
  22. <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>
  23. <B>Place Of Publication:</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Input Type="Text" Place Of Publication="Place Of Publication"><Br> <Br>
  24. <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">
  25.  
  26. <br></br>
  27. <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">
  28.  
  29. <Br> <Br>
  30. <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">
  31. <Br> <Br>
  32.  
  33. <Br> <Br>
  34. <Center><Input Type="Submit" Style="Font-Family:Monotype Corsiva;Color:Yellow;Font-Size:22;Font-Weight:Bold;Background:Brown" Value="Submit"></Center>
  35. </Form>
  36. </Body>
  37. </Html>
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. <%
  53. registry=Trim(Request.Form("registry"))
  54. Catergory = Trim(Request.Form("registry"))
  55. If Catergory= "Title" then
  56. Title = Trim(Request.Form("Title"))
  57. Author = Trim(Request.Form("Author"))
  58. ISBN = Trim(Request.Form("ISBN"))
  59. Publisher= Trim (Request.Form("Publisher"))
  60. Place_of_Publication= Trim(Request.Form("Place of Publication"))
  61. Year=Trim(Request.Form("Year"))
  62. Collation=Trim(Request.Form("Collation"))
  63. Shelf_Number=Trim(Request.Form("Shelf Number"))
  64.  
  65. If Title <>"" and Author <>"" and ISBN <>"" and Publisher <>"" and Place_of_Publication <>"" and Year <>"" and Collation <>"" and Shelf_Number<>"" Then
  66.  
  67.  
  68. <%
  69.  
  70. MyStatement = "Insert into Book_files Set Values
  71. Title='"&Title&"',Author='"&Author&"', ISBN='"&ISBN&"',Publisher='"&Publisher&"',Place_of_Publication='"& PlaceofPublication&"',Year='"&Year&"',Collation='"&Collation &"',Shelf_Number='"&ShelfNumber&"'" 
  72. Set Con = Server.CreateObject("SQLOLEDB")
  73. Con.Open "PROVIDER=SQLOLEDB;DATA SOURCE=master;UID=<hidden>;PWD=<hidden>;DATABASE=Book_files"
  74.  
  75. Con.Execute MyStatement
  76.  
  77. End IF
  78. End IF
  79.  
  80.  
  81.  
  82.  
  83.  
  84. %>
  85.  
  86. <Html>
  87. <Head><Title>Insert Data</Title></Head>
  88. <Body>
  89.  
  90. <Form Method="POST" action="/registry.html"><Head> <Center> <Font Color="Brown" Size=11 Face="Comic Sans Ms"> 
  91. Confirmation Page </Font> </Center>
  92.  
  93. <Body BGColor="Yellow">
  94. <Br><Br>
  95.  
  96. <%
  97.  
  98.  
  99. Response.Write(" Your Value Has Been Successfully Inserted In The Table!")
  100.  
  101.  
  102.  
  103.  
  104. End IF
  105.  
  106.  
  107. %>
  108.  
  109.  
  110. </Body>
  111.  
  112. </Html>
  113.  
Edited Code - Removed username and password for database from his code (also wrapped it in code tags) - iam_clint
Mar 13 '07 #10
jhardman
3,406 Expert 2GB
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:
Expand|Select|Wrap|Line Numbers
  1. <Input Type="Text" ISBN/ISSN="ISBN/ISSN">
and then get the data like this:
Expand|Select|Wrap|Line Numbers
  1. ISBN = Trim(Request.Form("ISBN"))
instead it should read:
Expand|Select|Wrap|Line Numbers
  1. <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:
Expand|Select|Wrap|Line Numbers
  1. 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:
Expand|Select|Wrap|Line Numbers
  1. response.write "Author: " & request.form("author") & "<br>" & vbNewLine
  2. '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
Expand|Select|Wrap|Line Numbers
  1. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  2. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  3. &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
Mar 13 '07 #11
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 .
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3.      <Head> <U> <Center><Font Color="Red" Face="Garamond" Size=11> Registration Book</Font> </Center> </U>
  4.           <Title>  Registration Page </Title>
  5.       </Head>
  6.       <Body Bgcolor="Pink">
  7.              <code> <Form Method="Post" Action="lala.asp?"> </code>
  8.                          <Br>  <Br>
  9.           <B>Title                             :</B> &nbsp;&nbsp;<Input Type="Text" Name="Title">
  10.                          <Br>   <Br>
  11.           <B>Author                             :</B>&nbsp;&nbsp;&nbsp;<Input Type="Text" Author="Author">
  12.                          <Br>   <Br>
  13.            <B>ISBN     :</B>&nbsp;&nbsp;&nbsp;<Input Type="Text" ISBN/ISSN="ISBN">
  14.                          <Br>   <Br>
  15.             <B>Publisher:</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp<Input Type="Text" Name="Publisher"><Br>   <Br>
  16.           <B>Place Of Publication:</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Input Type="Text" Place Of Publication="Place Of Publication"><Br>   <Br>
  17.           <B>Year:                                                                                                    </B>&nbsp;&nbsp;&nbsp;&nbsp;<Input Type="Text" Year="Year">
  18.  
  19. <br></br>
  20. <B>Collation              :</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Input Type="Text" Collation="Collation">
  21.  
  22. <Br>   <Br>
  23.            <B>Shelf Number         :</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Input Type="Text" Shelf Number="Shelf Number">
  24.                          <Br>   <Br>
  25.  
  26.                          <Br>   <Br>
  27. <Center><Input Type="Submit" Style="Font-Family:Monotype Corsiva;Color:Yellow;Font-Size:22;Font-Weight:Bold;Background:Brown" Value="Submit"></Center>
  28.              </Form>
  29.          </Body>
  30.   </Html>
ASP CODE
Expand|Select|Wrap|Line Numbers
  1. <%
  2. category = Trim(Request.Form("registry"))
  3. If category="Book_files" then
  4. Title = Trim(Request.Form("Title"))
  5. Author = Trim(Request.Form("Author"))
  6. ISBN = Trim(Request.Form("ISBN"))
  7. Publisher = Trim(Request.Form("Publisher"))
  8. Place_of_Publication = Trim(Request.Form("PlaceofPublication"))
  9. Year = Trim(Request.Form("Year"))
  10. Collation = Trim(Request.Form("Collation"))
  11. Shelf Number = Trim(Request.Form("ShelfNumber"))
  12. If CBookTitle<>"" AND CAuthor<>"" AND IISBN<>"" AND  CPublisher<>""AND CPlaceofPublication<>"" AND IYear<>"" AND CCollation<>"" AND IShelfNu<>"" Then
  13. MySQL = "Insert into Book_files(CBook_Titles,CAuthor,IISBN,CPublisher,CPlace_of_Publication,
  14. IYear,CCollation,IShelfNu
  15. Values('"&BookTitle&"','"&Author&"','"&ISBN&"','"Publisher&"','"&PlaceofPublication&"',
  16. '"&Year&"','"&Collation&"','"&ShelfNu&"')"
  17. Set con = Server.CreateObject("ADODB.Connection")
  18. Con.Open  "Provider=SQLOLEDB;Data Source=G144379\G144379;UID=sa;Pwd=sa;DataBase=Bruno;
  19.  
  20. response.write "Title: " & request.form("Title") & "<br>" & vbNewLine
  21. ',"Author: " & request.form("author") & "<br>" & vbNewLine
  22. ',"ISBN: " & request.form("ISBN") & "<br>" & vbNewLine
  23. ',"Publisher: " & request.form("Publisher") & "<br>" & vbNewLine
  24. ',"Place of Publication: " & request.form("Place of Publication") & "<br>" & vbNewLine
  25. ',"Year: " & request.form("Year") & "<br>" & vbNewLine
  26. ',"Collation: " & request.form("Collation") & "<br>" & vbNewLine
  27. ',"Shelf Number: " & request.form("Shelf Number") & "<br>" & vbNewLine
  28.  
  29. Con.Execute MySQL
  30. end if
  31.  
  32.  
  33.  
  34. %>
  35. <Html>
  36.    <Head> <Center> <Font Color="Brown" Size=11 Face="Comic Sans Ms"> 
  37. Confirmation Page </Font> </Center>
  38.         <Title> Results Returned By Active Server Pages </Title>
  39.    </Head>
  40.    <Body BGColor="Yellow">
  41.        <Br><Br>
  42.  
  43.  
  44. <%
  45.  
  46. Response.Write ("Your Value Has Been Successfully Inserted In The Table!")
  47.    End If
  48.  
  49.  
  50. %>
  51.  
  52.  
  53.    </Body>
  54. </Html>



SQL is Like This
Expand|Select|Wrap|Line Numbers
  1. Create  table Book_file
  2. (
  3. Title char(100)not null,
  4. Author char(100)not null,
  5. ISBN into,
  6. Publisher char(100),
  7. Place_of_Publisher char(100),
  8. Year into,
  9. Collation varchar(100),
  10. Shelf_number int
  11. )
Mar 14 '07 #12
jhardman
3,406 Expert 2GB
try this exact code. Don't change a thing:
Expand|Select|Wrap|Line Numbers
  1. <%
  2. if request.form("title") = "" then %>
  3.     <html>
  4.         <Head>
  5.             <Title>Registration Page</Title>
  6.             <style>
  7.                 <!--
  8.  
  9.                 label {
  10.                     color: black;
  11.                     position: relative;
  12.                     left: 40px;
  13.                 }
  14.  
  15.                 input {
  16.                     position: absolute;
  17.                     top: inherit;
  18.                     left: 220px;
  19.                 }
  20.  
  21.                 fieldset {
  22.                     border: 0px;
  23.                     padding: 5px;
  24.                 }
  25.  
  26.                 -->
  27.             </style>
  28.         </head>
  29.         <body style="background-color: pink">
  30.             <h1 style="text-align: center; text-decoration: underline;font:Garamond 
  31.             san-serif 16pt;color:'Red'"> Registration Book</h1>
  32.             <Form Method="Post" Action="lala.asp">
  33.                 <fieldset><label for="title">Title:</label><input type="text" 
  34.                 name="title" value="<%=request.form("title")%>"></fieldset>
  35.                 <fieldset><label for="author">Author:</label><Input type="text" 
  36.                 name="author" value="<%=request.form("author")%>"></fieldset>
  37.                 <fieldset><label for="isbn">ISBN/ISSN:</label><Input type="text"
  38.                  name="isbn" value="<%=request.form("isbn")%>"></fieldset>
  39.                 <fieldset><label for="publisher">Publisher:</label><Input type="text"
  40.                  name="publisher" value="<%=request.form("publisher")%>"></fieldset>
  41.                 <fieldset><label for="place">Place of Publication:</label><Input
  42.                  type="text" name="place" value="<%=request.form("place")%>"></fieldset>
  43.                 <fieldset><label for="year">Year:</label><Input type="text" 
  44.                 name="year" value="<%=request.form("year")%>"></fieldset>
  45.                 <fieldset><label for="collation">Collation:</label><Input
  46.                  type="text" value="<%=request.form("collation")%>" name="collation"></fieldset>
  47.                 <fieldset><label for="shelf">Shelf Number:</label><Input
  48.                  type="text" name="shelf" value="<%=request.form("shelf")%>"></fieldset>
  49.                 <fieldset style="text-align: center"><Input type="submit"
  50.                  style="Font-Family:Monotype Corsiva;
  51.                     Color:Yellow;Font-Size:22;Font-Weight:Bold;Background:Brown"
  52.                  Value="Submit"></fieldset>
  53.  
  54.             </Form>
  55.         </Body>
  56.     </Html>
  57.  
  58. <%
  59. else
  60.     'category = Trim(Request.Form("registry"))
  61.     'If category="Book_files" then
  62.         dim fld, inp, objCon, objRS
  63.         for each inp in request.form
  64.             response.write inp & ": " & request.form(inp) & "<br>" & vbNewLine
  65.         next
  66.  
  67.         'Title = Trim(Request.Form("Title"))
  68.         'Author = Trim(Request.Form("Author"))
  69.         'ISBN = Trim(Request.Form("ISBN"))
  70.         'Publisher = Trim(Request.Form("Publisher"))
  71.         'Place_of_Publication = Trim(Request.Form("PlaceofPublication"))
  72.         'Year = Trim(Request.Form("Year"))
  73.         'Collation = Trim(Request.Form("Collation"))
  74.         'Shelf Number = Trim(Request.Form("ShelfNumber"))
  75.         'If CBookTitle<>"" AND CAuthor<>"" AND IISBN<>"" AND CPublisher<>""AND CPlaceofPublication<>"" AND IYear<>"" AND CCollation<>"" AND IShelfNu<>"" Then
  76.         'MySQL = "Insert into Book_files(CBook_Titles,CAuthor,IISBN,CPublisher,C Place_of_Publication,IYear,CCollation,IShelfNu
  77.         'Values('"&BookTitle&"','"&Author&"','"&ISBN&"','"Publisher&"','"& PlaceofPublication&"','"&Year&"','"&Collation&"','"&ShelfNu&"')"
  78.         Set objCon = Server.CreateObject("ADODB.Connection")
  79.         objCon.Open "Provider=SQLOLEDB;Data Source=G144379\G144379;UID=sa;Pwd=sa;DataBase=Brun o;
  80.         set objRS = Server.CreateObject("ADODB.Recordset")
  81.         objRS.open "SELECT * FROM [Book_files]", objCon
  82.  
  83.         for each fld in objRS.fields
  84.             response.write fld.name & "<br>" & vbNewLine
  85.         next
  86.  
  87.         'response.write "Title: " & request.form("Title") & "<br>" & vbNewLine
  88.         ',"Author: " & request.form("author") & "<br>" & vbNewLine
  89.         ',"ISBN: " & request.form("ISBN") & "<br>" & vbNewLine
  90.         ',"Publisher: " & request.form("Publisher") & "<br>" & vbNewLine
  91.         ',"Place of Publication: " & request.form("Place of Publication") & "<br>" & vbNewLine
  92.         ',"Year: " & request.form("Year") & "<br>" & vbNewLine
  93.         ',"Collation: " & request.form("Collation") & "<br>" & vbNewLine
  94.         ',"Shelf Number: " & request.form("Shelf Number") & "<br>" & vbNewLine
  95.  
  96.         'Con.Execute MySQL
  97.     'end if %>
  98.  
  99.     <Html>
  100.     <Head> <Center> <Font Color="Brown" Size=11 Face="Comic Sans Ms">
  101.     Confirmation Page </Font> </Center>
  102.     <Title> Results Returned By Active Server Pages </Title>
  103.     </Head>
  104.     <Body BGColor="Yellow">
  105.     <Br><Br>
  106.     <%
  107.  
  108.     'Response.Write ("Your Value Has Been Successfully Inserted In The Table!")
  109. End If %>
  110.  
  111. </Body>
  112. </Html>
  113.  
  114. <!--
  115.  
  116. SQL is Like This
  117.  
  118. Create table Book_file
  119. (
  120. Title char(100)not null,
  121. Author char(100)not null,
  122. ISBN into,
  123. Publisher char(100),
  124. Place_of_Publisher char(100),
  125. Year into,
  126. Collation varchar(100),
  127. Shelf_number int
  128. )
  129. -->
Save the entire thing as one file named lala.asp. Run it and let me know what happened
Mar 14 '07 #13
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.
Mar 15 '07 #14
jhardman
3,406 Expert 2GB
OK, try this variation. I put it up on one of my development sites, but the domain registration just ran out...

Jared
Expand|Select|Wrap|Line Numbers
  1. <%
  2. if request.form("title") = "" then %>
  3.     <html>
  4.         <Head>
  5.             <Title>Registration Page</Title>
  6.             <style>
  7.                 <!--
  8.  
  9.                 label {
  10.                     color: black;
  11.                     position: relative;
  12.                     left: 40px;
  13.                 }
  14.  
  15.                 input {
  16.                     position: absolute;
  17.                     top: inherit;
  18.                     left: 220px;
  19.                 }
  20.  
  21.                 fieldset {
  22.                     border: 0px;
  23.                     padding: 5px;
  24.                 }
  25.  
  26.                 -->
  27.             </style>
  28.         </head>
  29.         <body style="background-color: pink">
  30.             <h1 style="text-align: center; text-decoration: underline;font:Garamond 
  31.             san-serif 16pt;color:'Red'"> Registration Book</h1>
  32.             <Form Method="Post" Action="lala.asp">
  33.                 <fieldset><label for="title">Title:</label><input type="text" 
  34.                 name="title" value="<%=request.form("title")%>"></fieldset>
  35.                 <fieldset><label for="author">Author:</label><Input type="text" 
  36.                 name="author" value="<%=request.form("author")%>"></fieldset>
  37.                 <fieldset><label for="isbn">ISBN/ISSN:</label><Input type="text"
  38.                  name="isbn" value="<%=request.form("isbn")%>"></fieldset>
  39.                 <fieldset><label for="publisher">Publisher:</label><Input type="text"
  40.                  name="publisher" value="<%=request.form("publisher")%>"></fieldset>
  41.                 <fieldset><label for="place">Place of Publication:</label><Input
  42.                  type="text" name="place" value="<%=request.form("place")%>"></fieldset>
  43.                 <fieldset><label for="year">Year:</label><Input type="text" 
  44.                 name="year" value="<%=request.form("year")%>"></fieldset>
  45.                 <fieldset><label for="collation">Collation:</label><Input
  46.                  type="text" value="<%=request.form("collation")%>" name="collation"></fieldset>
  47.                 <fieldset><label for="shelf">Shelf Number:</label><Input
  48.                  type="text" name="shelf" value="<%=request.form("shelf")%>"></fieldset>
  49.                 <fieldset style="text-align: center"><Input type="submit"
  50.                  style="Font-Family:Monotype Corsiva;
  51.                     Color:Yellow;Font-Size:22;Font-Weight:Bold;Background:Brown"
  52.                  Value="Submit"></fieldset>
  53.  
  54.             </Form>
  55.         </Body>
  56.     </Html>
  57.  
  58. <%
  59. else
  60.     'category = Trim(Request.Form("registry"))
  61.     'If category="Book_files" then
  62.         dim fld, inp, objCon, objRS
  63.         for each inp in request.form
  64.             response.write inp & ": " & request.form(inp) & "<br>" & vbNewLine
  65.         next
  66.  
  67.         'Title = Trim(Request.Form("Title"))
  68.         'Author = Trim(Request.Form("Author"))
  69.         'ISBN = Trim(Request.Form("ISBN"))
  70.         'Publisher = Trim(Request.Form("Publisher"))
  71.         'Place_of_Publication = Trim(Request.Form("PlaceofPublication"))
  72.         'Year = Trim(Request.Form("Year"))
  73.         'Collation = Trim(Request.Form("Collation"))
  74.         'Shelf Number = Trim(Request.Form("ShelfNumber"))
  75.         'If CBookTitle<>"" AND CAuthor<>"" AND IISBN<>"" AND CPublisher<>""AND CPlaceofPublication<>"" AND IYear<>"" AND CCollation<>"" AND IShelfNu<>"" Then
  76.         'MySQL = "Insert into Book_files(CBook_Titles,CAuthor,IISBN,CPublisher,C Place_of_Publication,IYear,CCollation,IShelfNu
  77.         'Values('"&BookTitle&"', '"&Author&"', '"&ISBN&"', '"Publisher&"', '"&PlaceofPublication&"', '"&Year&"', '"&Collation&"', '"&ShelfNu&"')"
  78.         'Set objCon = Server.CreateObject("ADODB.Connection")
  79.         'objCon.Open "Provider=SQLOLEDB;Data Source=G144379\G144379;UID=sa;Pwd=sa;DataBase=Brun o;
  80.         'set objRS = Server.CreateObject("ADODB.Recordset")
  81.         'objRS.open "SELECT * FROM [Book_files]", objCon
  82.  
  83.         'for each fld in objRS.fields
  84.         '    response.write fld.name & "<br>" & vbNewLine
  85.         'next
  86.  
  87.         'response.write "Title: " & request.form("Title") & "<br>" & vbNewLine
  88.         ',"Author: " & request.form("author") & "<br>" & vbNewLine
  89.         ',"ISBN: " & request.form("ISBN") & "<br>" & vbNewLine
  90.         ',"Publisher: " & request.form("Publisher") & "<br>" & vbNewLine
  91.         ',"Place of Publication: " & request.form("Place of Publication") & "<br>" & vbNewLine
  92.         ',"Year: " & request.form("Year") & "<br>" & vbNewLine
  93.         ',"Collation: " & request.form("Collation") & "<br>" & vbNewLine
  94.         ',"Shelf Number: " & request.form("Shelf Number") & "<br>" & vbNewLine
  95.  
  96.         'Con.Execute MySQL
  97.     'end if %>
  98.  
  99.     <Html>
  100.     <Head> <Center> <Font Color="Brown" Size=11 Face="Comic Sans Ms">
  101.     Confirmation Page </Font> </Center>
  102.     <Title> Results Returned By Active Server Pages </Title>
  103.     </Head>
  104.     <Body BGColor="Yellow">
  105.     <Br><Br>
  106.     <%
  107.  
  108.     'Response.Write ("Your Value Has Been Successfully Inserted In The Table!")
  109. End If %>
  110.  
  111. </Body>
  112. </Html>
  113.  
  114. <!--
  115.  
  116. SQL is Like This
  117.  
  118. Create table Book_file
  119. (
  120. Title char(100)not null,
  121. Author char(100)not null,
  122. ISBN into,
  123. Publisher char(100),
  124. Place_of_Publisher char(100),
  125. Year into,
  126. Collation varchar(100),
  127. Shelf_number int
  128. )
  129. -->
Mar 16 '07 #15
I just got text the Box Which I was suppoused to key in some words. I saved it with ASP and HTML to try to fined if they will be any defference. And it show the same error i was talking about last time. a mixure of words and codes. you > just on in top like a stamp
Mar 19 '07 #16
Hi bseakgano,

It is very difficult to understand your problem because of the way you presented.

ok come to the point.u want to insert a record to the database right,

i ve seen your code u have used if statement where is the else part firtst.since there is nothing(i mean any field left blank) it will not insert any record to the database your codings means that.

so please restrict the input information first with regularities.

i'll write some simple codings to u pls make use of it.i have done using access database i think u r using SQL ,just change the connection setup i mean provider name try to amend your code as the below

just try with the below code make atleast one record to sit in the database first then u amend as per your requirement

create one table of the following fields

name
age
comment(u choose any thing)

Expand|Select|Wrap|Line Numbers
  1. <html><body>
  2.  
  3. <%
  4.  
  5. If Request.Form("ClearButton") = "Clear Form" Then
  6.     name = ""
  7.   age = ""
  8.   comment =""
  9.   End If
  10.  
  11. If Request.Form("AddButton") = "Add Record" Then
  12.     date = Now()
  13.     name = Request.Form("name")
  14.   age = Request.Form("age")
  15.   comment = Request.Form("comment")
  16.  
  17.   Valid = True
  18.  
  19.   ' -- Check name for blanks
  20. If name = "" Then
  21.     Msg1 = "Name is required."
  22.     Valid = False
  23.   End If
  24.  ' -- Check age for blanks
  25.   If age = "" Then
  26.     Msg2 = "Select your age."
  27.     Valid = False
  28.   End If
  29.  
  30. ' -- Check comment for blanks
  31.   If comment = "" Then
  32.     Msg3 = "write some comment"
  33.     Valid = False
  34.   End If
  35.  
  36.  
  37.   '-- Write new record to table
  38.    If Valid = True Then
  39.    Set CNObj = Server.CreateObject("ADODB.Connection")
  40.     'write your driver name instead of access driver
  41.     CNObj.Open "DBQ=C:\Inetpub\wwwroot\manage\ivr.mdb;DRIVER=Microsoft Access Driver (*.mdb)"
  42.     Set RSAdd = Server.CreateObject("ADODB.Recordset")
  43.     SQL = "SELECT * FROM tablename WHERE Null"
  44.     RSAdd.Open SQL, CNObj, 1,3,1
  45.  
  46.     RSAdd.AddNew
  47.     RSAdd.Fields("name") = name
  48.     RSAdd.Fields("age") = age
  49.     RSAdd.Fields("comment") = comment
  50.  
  51.     RSAdd.Update
  52.  
  53.  Msg = "Record has inserted in table"
  54.     RSAdd.Close
  55.     CNObj.Close
  56.  
  57.   End If
  58.  
  59. End If
  60. %>
  61.  
  62.  
  63. <html>
  64. <body>
  65.  
  66. <form action="samepage.asp" method="post">
  67.   <table border="1" align="center">
  68. <tr>
  69.   <th>Date/Time:</th>
  70.   <td><%=Now()%></td>
  71. </tr>
  72. <tr>
  73.   <th>Name: </th>
  74.   <td><input name="Itemadd3" type="text" size="50" maxlength="50" value="<%=Itemadd3%>">
  75.       <%=Msg1%></td>
  76. </tr>
  77. <tr>
  78.   <th>Age:</th> <td> <input type="text" name="age"> <%=Msg2%></td>
  79. </tr> 
  80. <tr>
  81.   <th>Comment: </th>
  82.   <td><label>
  83.     <textarea name="Itempair"><%=Itempair%></textarea><%=Msg3%>
  84.   </label></td>
  85. </tr>
  86. </table>
  87. <br>
  88. <center>
  89. <input type="submit" name="AddButton" value="Add Record">
  90. <input type="submit" name="ClearButton" value="Clear Form"><%=Msg%>
  91. </center>
  92. </form>
  93.  
  94. </body>
  95. </html>
  96.  
  97.  
  98.  
  99.  


Try with the above code and let me know.

bye
Mar 19 '07 #17
Now the Code look to have problem with <form action="samepage.asp" method="post"> it triad not to change so that I can know . I saved it with HTML . It shows me another Window Saying C:\Inetpub\wwwroot\samepage.asp which is it want a an asp file . though I have saved them both in one page . Please you help with an asp file.
Mar 20 '07 #18
Dear,

don't separate it as HTML and ASP .

u can save any codings with .html also and .asp also no differnences..ok.

now copy paste the code which i sent to u and save that file with

filename.asp

then go to form tag and amend

<form action="filename">

so that it will execute and refresh in the same page.

reply me with your problems now.
Mar 21 '07 #19
jhardman
3,406 Expert 2GB
I just got text the Box Which I was suppoused to key in some words. I saved it with ASP and HTML to try to fined if they will be any defference. And it show the same error i was talking about last time. a mixure of words and codes. you > just on in top like a stamp
You know what? I think your server is not set up to handle scripts. Itried this in my server (just before it crashed, sorry you can't see) and it worked fine. Can you handle very simple scripts like <%="Hello world"%>?

Jared
Mar 22 '07 #20
It is like I am calling the code . when I click the button , hoping that it will be inserting information into the Database , I just get the code . But when I save the whole code into one thing . It just take me to the weather information. It is strange . I asked myself a question like which code here deals with weather but I found none. Hope I will get a message like you code had been inserted into the database .


Jared ,When I try to right something like hello . it just do as that , hello get displayed . But the problem arise when I try to link it with SQL. OR is the installation of ASP I donít know . I really want want to do this
Mar 22 '07 #21
jhardman
3,406 Expert 2GB
Jared ,When I try to right something like hello . it just do as that , hello get displayed . But the problem arise when I try to link it with SQL. OR is the installation of ASP I donít know . I really want want to do this
It doesn't make sense to me that the script should break when it encounters the SQL code. It is as if your server stops handling the scripts. At very least it should give an error message. Which server are you using?

Jared
Mar 22 '07 #22
jhardman
3,406 Expert 2GB
It doesn't make sense to me that the script should break when it encounters the SQL code. It is as if your server stops handling the scripts. At very least it should give an error message. Which server are you using?

Jared
Sorry, I read back and saw that you did answer that. It still doesn't make sense. It sounds like it is a problem with how your IIS is configured, but all I can do is scratch my head at this point. Can someone else reading this confirm that the codes we posted work? I tested it, but then my domain registration ran out, so I can't show how it works. Subashini, did you test this?

Jared
Mar 22 '07 #23
Hi,
I am really confused by the way u people are communicating.
Let her first draft a clear picture about her problems.then we can start giving suggestions to her.

I send the codings with simple explanation,please read it properly if u do copy paste nothing will work.try to understand line by line then to implement.whereever the file name required please provide it then come to me.

i 'll really help u.
ok bye
Mar 25 '07 #24
Am using VB.Net though it is my first time to use it . I just want to insert , delete , seach, update pictures into database, I want to using vb.net and forms(ASP) to insert pictures into SQL. Please help with 2 to 3 lines. I mean how SQL should look, Vb.net should (connect) look, forms should (connect) look. Believe that three line of codes from each can help a lot
Mar 26 '08 #25
jhardman
3,406 Expert 2GB
Am using VB.Net though it is my first time to use it . I just want to insert , delete , seach, update pictures into database, I want to using vb.net and forms(ASP) to insert pictures into SQL. Please help with 2 to 3 lines. I mean how SQL should look, Vb.net should (connect) look, forms should (connect) look. Believe that three line of codes from each can help a lot
That may be your problem!

This is the ASP forum, for ASP.NET questions, please post in the .NET forum.

Jared
Mar 27 '08 #26

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Jared Evans | last post by:
I developed a console application that will continually check a message queue to watch for any incoming data that needs to be inserted into MS SQL...
2
by: altergothen | last post by:
Hi there I am a newbie to ASP.Net - Please Help! I am trying to insert the values of my variables into a database. If I try the following it...
5
by: hfk0 | last post by:
Hi, I'm new to ASP.net, SQL Server and visual studio.net, and I'm having problem inserting and storing data from a web form to a SQL database. ...
11
by: c676228 | last post by:
Hi everyone, I am just wodering in asp program, if there is anybody writing store procedure for inserting data into database since there are so...
6
by: arial | last post by:
Hi all I am getting this error message while try to insert data using my .net webform. Exception Details: System.Data.SqlClient.SqlException: Line...
4
vikas1111
by: vikas1111 | last post by:
Hi All.. While putting data into database from form if i refresh the php form a blank data will be added into database ... How can i remove...
18
by: boss1 | last post by:
Hi all, i m having a problem with inserting data in oracle db. When i use form action =(call self page) then data is inserting properly.But...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site...
4
by: makweatan | last post by:
hI GUYS... seems that I cant insert data into table. I got this error: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: REASON;ECT =...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.