链接字符串:$System.Data.OleDb$Provider=Microsoft.Jet.OLEDB.4.0;Data Source=LoginSet.mdb SQL字符串:select * from [Table] where ZTS = 'zts'
string strSql = string.Format("select * from FinalData where DateTime>#{0}#", dTime);
Postgresql
链接字符串:$Npgsql$Database=LocalDB;Host=LocalHost;Port=5432;Username=postgres;Password=123 SQL字符串:select * from [Table] where VIN='vin' order by ID desc string strLocalSql = string.Format("select * from [四轮表] order by [测试时间] desc limit 1");
判断字段中包含某字符串所在位
select * from [车型库] where POSITION('{0}' in [VIN])>0 eg:postion('abc' in '123abc123')—>4
时间判断
SELECT * FROM [FAS表] where [VIN]='{0}' and to_char([测试时间],'yyyy-MM-dd HH24:MI:ss')='{1}' limit 1
SQLServer
SQLServer字符串:$System.Data.SqlClient$Data Source=EOLSERVICE;Initial Catalog=EOLData;Persist Security Info=True;User ID=sa;Password=321 SQL字符串:select * from [Table] where VIN='vin' order by ID desc
SQLServer判断字段中包含某字符串所在位
select * from [车型库] where charindex('{0}',[VIN])>0
MySqlConnection myconn = new MySqlConnection("server=10.102.62.26;database=cartest_reporter;user id=root;password=root;Charset=utf8"); myconn.Open(); MySqlCommand mycom = myconn.CreateCommand(); mycom.CommandText = "SELECT *FROM student1"; MySqlDataAdapter adap = new MySqlDataAdapter(mycom); MySqlCommandBuilder mysqlcb = new MySqlCommandBuilder(adap);// insert DataTable dt = new DataTable(); adap.Fill(dt);
/*string MES_ConnStr = @"server = 10.23.1.67;Uid = testams;Pwd = test@ams;database= test;CharSet=utf8"; MySqlConnection conn = new MySqlConnection(MES_ConnStr); if (conn.State != ConnectionState.Open) conn.Open(); strOra_Sql = string.Format("select * from {0}", MESTableName); MySqlDataAdapter sdap = new MySqlDataAdapter(); MySqlCommand mycmdFind = new MySqlCommand(strOra_Sql, conn); MySqlCommandBuilder cb = new MySqlCommandBuilder(sdap); DataTable dt = new DataTable(); sdap.SelectCommand = mycmdFind; sdap.Fill(dt); DataRow dr = dt.NewRow(); foreach (string s in ListMap.Keys) { dr[s] = drEOL[ListMap[s]]; } dt.Rows.Add(dr); sdap.Update(dt); conn.Close();*/
Excel
1 2 3 4 5 6 7
DataSet ds = new DataSet(); OleDbConnection conn = new OleDbConnection(strConn); string sql = string.Format("select * from [{0}$] where [VIN] like '%{1}%'", sourceTableName, VINString); OleDbDataAdapter oada = new OleDbDataAdapter(sql, conn); oada.Fill(ds); foreach (DataRow drr in ds.Tables[0].Rows)