SQL Server adds data to

Source: Internet
Author: User

Here's how SQL Server adds data to the database.

 <!--Add host information --         <Form action="Add_admin.jsp" method="POST">  <TableAlign="Center">   <Tr>    <Td>Add a book:</Td>   </Tr>    <Tr>    <Td>Please enter the title:</Td>    <Td><input type="text"Name="Name"></Td>    </Tr>     <Tr>    <Td>Please enter the price:</Td>    <Td><input type="text"Name="Health"></Td>    </Tr>    <Tr>    <Td>Please enter the degree of love:</Td>    <Td><input type="text"Name="Love"></Td>    </Tr>    <Tr>    <Td>Please enter</Td>    <Td><input type="text"Name="Strain"></Td>    </Tr>         <TR colspan=2>          <Td><input type="Submit" value="Submit" style="Margin-left: 0px;color:red;background: #8D0023 "></Td>           <Td><input type="Reset" value="Reset" style="Margin-left: 50px;color:red;background: #8D0023 "></Td>              </Tr>      </Table>   </Form>     


To process a committed statement:

<%@ Page Language="Java" Import="Java.util.*"Pageencoding="UTF-8"%><%@pageImport="Jdbc.sqlserver"%><%@pageImport="Java.sql.Connection"%><%@pageImport="Java.sql.ResultSet"%><%@pageImport="Java.sql.PreparedStatement"%><%String name=request.getparameter ("name"); Name=New String (Name.getbytes ("ISO-8859-1")," utf-8"); String Health=request.getparameter ("Health"); String Love=Request.getparameter ("Love"); String Strain=Request.getparameter ("strain"); Strain=New String (Strain.getbytes ("ISO-8859-1")," utf-8"); //Reference Connection database method SQL Server sq=new SQL Server (); //Get database connection Connection con=sq.getconnection (); //write SQL statement String SQL="Insert  intoDogValues (?,?,?,?)";                    //Get database Operations Object PreparedStatement St=con.preparestatement (SQL); St.setstring (1, name); St.setstring (2, health); St.setstring (3, Request.getparameter ("Love")); St.setstring (4, strain); //get the results of the queryif(St.executeupdate ()>0){          %>              <Script type="text/JavaScript>alert ("Add success"); Location="showlog.jsp"; </Script>          <%                   }Else{                            %>              <Script type="text/JavaScript>alert ("Add failed"); Location="showlog.jsp"; </Script>          <%                               }                   %>     

SQL Server adds data to

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.