First create a new database table
PRIMARY KEY (JY_ID)- Represents a unique primary key
-- Create a table in the database CREATE TABLE MYBAIDUJYLIST( JY_ID VARCHAR(200) NOT NULL,-- Unique identification
JY_BH VARCHAR(200) NOT NULL,-- number JY_MC VARCHAR(200) NOT NULL,-- name JY_ViewCount
int,-- Views JY_DZCount int,-- Number of likes JY_TPCount int,-- number of votes JY_IFXS VARCHAR(10),-- Yes or no
JY_FBTime varchar(100),-- Release time -- yyyymmdd PRIMARY KEY (JY_ID)-- Primary key field only )
select You can query the contents of the data table , and insert Is the result of inserting the database `
VALUES(NEWID(),'fb00001',' test data ',100,2,13,1,'20191112')-- insert data
and C# You can connect to the database through simple configuration
The comparison is as follows
Through the simple configuration of the current database related information , As follows sql server Data related information
Data Source= Server name ;Initial Catalog= Database name ;User ID = user name ;Pwd = password
The following code can query the relevant data table data of the database table , And insert a piece of data , The insert data must exist sqlc.ExecuteNonQuery();
//connString = "Data Source= Server name ;Initial Catalog= Database name ;User ID = user name ;Pwd =
password "; // You need to connect to the server name separately Database name user name The password can connect correctly conn.ConnectionString = connString;
conn.Open(); // Open database connection // query sql String sql = " select * from MYBAIDUJYLIST"; //
Query statement SqlDataAdapter myda = new SqlDataAdapter(sql, conn); // Instantiation adapter DataTable
dt = new DataTable(); // Instantiation data table myda.Fill(dt); // insert sql sql = "INSERT INTO
(JY_ID,JY_BH,JY_MC,JY_ViewCount,JY_DZCount,JY_TPCount,JY_IFXS,JY_FBTime)VALUES(NEWID(),'fb00001',' test data ',100,2,13,1,'20191112')";
//;" select * from MYBAIDUJYLIST"; // Query statement SqlCommand sqlc = new
SqlCommand(sql, conn); sqlc.ExecuteNonQuery(); conn.Close(); // Close database connection

©2020 ioDraw All rights reserved
Swing actual combat Understanding closure about vue in el-date-picker type=daterange The problem of date not echoing Ubuntu 18.04 swap Partition expansion Snake code --c Language Edition visual c++6.0 open 【Golang Basic series 10 】Go language On conditional sentences ifString class —— summary ,String The nature of , Memory resolution , Commonly used APIAdobe Illustrator Publish native support Apple Silicon Test version of the software study java My first class antd table sort