Team work --- Step 1

Source: Internet
Author: User

Today, our team DOOM allocates work, and our team is responsible for the search of this site and Upload/Download content modules in the Online System.

My task is the search function in the search of this site. The function is to find data that matches the user's search Content from the database in the Content Pipeline group, and pass the written data to the sort sorting function (priority ).

My work platform is win7 32bit, Visual Studio 2012, Microsoft SQL Server 2008 R2.

Today I learned how to create a SQL database and create a file list (for testing ):

Learn how to connect to SQL in C #

Static void Main (string [] args) {OpenSqlConnection (); // open the database} private static void OpenSqlConnection () {string connectionString = GetConnectionString (); using (SqlConnection connection = new SqlConnection (connectionString) // instantiate the SQL connection class {connection. open (); // Open the Database Console. writeLine ("ServerVersion: {0}", connection. serverVersion); Console. writeLine ("State: {0}", connection. state) ;}} static private string GetConnectionString () {// To avoid storing the connection string in your code, // you can retrieve it from a configuration file, using the // System. configuration. configurationSettings. deleetaskproperty return "Data Source = .; initial Catalog = STUDENT; Integrated Security = SSPI; "; // SQL Server link string}

Test run:

To export the selected data from the database (part of the Code ):

Using System; using System. collections. generic; using System. linq; using System. text; using System. threading. tasks; using System. data. sqlClient; using System. data; namespace sqltest {class Program {static void Main (string [] args) {// OpenSqlConnection (); // open the database string connectionString = GetConnectionString (); // SQL Server connection string SqlConnection connection = new SqlConnection (connectionString); // instantiate the SQL connection class string strSQL = "SELECT title FROM FILE "; // SQL statement SqlDataAdapter da = new SqlDataAdapter (strSQL, connection); // create a DataAdapter data adapter instance DataSet ds = new DataSet (); // create a DataSet instance da. fill (ds, "test"); // use the Fill method of DataAdapter (Fill), call the SELECT command/* foreach (DataTable table in ds. tables) {foreach (DataRow row in table. rows) {foreach (DataColumn column in table. columns) {Console. writeLine (row [column]) ;}} */connection. close (); // Close the database}/* private static void OpenSqlConnection () {string connectionString = GetConnectionString (); using (SqlConnection connection = new SqlConnection (connectionString )) // instantiate the SQL link class {connection. open (); // Open the Database Console. writeLine ("ServerVersion: {0}", connection. serverVersion); Console. writeLine ("State: {0}", connection. state) ;}} */static private string GetConnectionString () {// To avoid storing the connection string in your code, // you can retrieve it from a configuration file, using the // System. configuration. configurationSettings. deleetaskproperty return "Data Source = .; initial Catalog = STUDENT; Integrated Security = SSPI; "; // SQL Server link string }}}

In the future, the function aims to match the data retrieved from the database with user input (call match () and send the processed data to the sort () sorting module.

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.