In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The code to connect to SQL Server in C #:
String con, sql; con = "Server=.;Database= temperature and humidity test; Trusted_Connection=SSPI"; sql = "select * from temperature and humidity test"; SqlConnection mycon = new SqlConnection (con); DateTime uploadDate = System.DateTime.Now; mycon.Open (); SqlDataAdapter myda = new SqlDataAdapter (sql, con); DataSet myds = new DataSet (); myda.Fill (myds, "temperature and humidity test") String sql2 = "insert into temperature and humidity Test (date, time, temperature, humidity) values ('" + uploadDate + "','" + uploadDate + "','" + wendu + ",'" + shidu + "')"; SqlDataAdapter myda2 = new SqlDataAdapter (sql2, mycon); myda2.Fill (myds, "temperature and humidity Test"); dataGridView1.DataSource = myds.Tables ["temperature and humidity Test"]; mycon.Close ()
Here is the code for the C# link SQLite:
/ / sqlite database string uploadDate = System.DateTime.Now.ToShortDateString () .ToString (); string uploadTime = System.DateTime.Now.ToLongTimeString () .ToString (); SQLiteConnection conn = null; string dbPath = "Data Source =" + "C:/sqlite" + "/ data test .db"; conn = new SQLiteConnection (dbPath); / / create a database instance and specify the file location conn.Open () / / Open the database, and automatically create string sql = "CREATE TABLE IF NOT EXISTS'" + "temperature" + uploadDate + "'(date varchar (6), time varchar (6), temperature varchar (6)) if the file does not exist; / / create the table statement SQLiteCommand cmdCreateTable = new SQLiteCommand (sql, conn); cmdCreateTable.ExecuteNonQuery (); / / if the table does not exist, create the data table SQLiteCommand cmdInsert = new SQLiteCommand (conn) CmdInsert.CommandText = "INSERT INTO'" + "temperature" + uploadDate + "'VALUES ('" + uploadDate + "','" + uploadTime + "','" + wendu + "')"; / / insert several pieces of data cmdInsert.ExecuteNonQuery (); conn.Close ()
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.