ASP.NET Excelµ¼Èëµ½SQL ServerÊý¾Ý¿â
ASP.NET Excelµ¼Èëµ½SQL ServerÊý¾Ý¿â
Ìṩ°ÑExcelÀïµÄÊý¾Ýµ¼Èëµ½SQL Server Êý¾Ý¿â£¬Ç°ÌáÊÇExcelÀïµÄ×Ö¶ÎÔÚSql Server±íÀﶼÓУ¬²»È»»á³öÏÖ´íÎó¡£×¢ÊͺÜÏêϸŶ£¡ÒªÒýÓõÄÃüÃû¿Õ¼äÊÇ£º
using System.Data.OleDb;
using System.Data.SqlClient;
//²Ù×÷Àà
public class ExcelToSQL
{
//string SqlConnectionString = "Server=(local);Initial Catalog=Test;Integrated Security=True";
public SqlConnection sqlcon; //´´½¨SQLÁ¬½Ó
public SqlCommand sqlcom; //´´½¨SQLÃüÁî¶ÔÏó
public ExcelToSQL()
{
DataOperation dataOperation = new DataOperation(); //Óõ½Æ½Ì¨µÄº¯Êý£¬¾ÍÊdzõʼ»¯SqlConnection¶ÔÏó
DBUnit dbUnit = dataOperation.GetDbUnit();
sqlcon = (SqlConnection)dbUnit.cnt;
if (sqlcon.State.ToString() == "Open")
sqlcon.Close();
}
public int ImportSql(string excelPath, string tableName) //µ¼ÈëµÄExcelµÄ·¾¶£¬Êý¾Ý¿âÀïµÄ±íÃû
{
if (!TableExist(tableName)) //±íÃûÊÇ·ñ´æÔÚ
return (int)ImportState.tableNameError;
DataTable dt = ExcelToDataTable(excelPath);
if (dt == null)
{
&nbs
Ïà¹ØÎĵµ£º
SELECT tagid, tagname from uchome_mtag WHERE tagname IN (SELECT tagname from uchome_mtag GROUP BY tagname HAVING (COUNT(tagname) > 1)) ORDER BY tagname ......
ÈýÖÖSQL·ÖÒ³·¨Ð§ÂÊ·ÖÎö
±íÖÐÖ÷¼ü±ØÐëΪ±êʶÁУ¬[ID] int IDENTITY (1,1)
1.·ÖÒ³·½°¸Ò»£º(ÀûÓÃNot InºÍSELECT TOP·ÖÒ³)
¡¡Óï¾äÐÎʽ£ºÀûÓÃNot InºÍSELECT TOP·ÖÒ³) ЧÂÊÖУ¬ÐèҪƴ½ÓSQLÓï¾ä
SELECT TOP 10 * from TestTable WHERE (Id NOT IN (SELECT TOP 20 id&n ......
¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
¡¡¡¡2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Data.Common;
using System.Data;
namespace DownData.dal
{
public static class DBHelper
{
private stati ......
ASP.NET CacheÖ§³ÖÈýÖÖÀàÐÍ
Ïëдһ¸ö¼¼Êõ¿ìËÙ¸ÅÊö£¬¿ÉÄÜдµÃÌ«¶àÁË¡£¼¼Êõ¸ÅÂÔµÄÄ¿µÄÊÇÒÔ×î¿ì×î¼òµ¥µÄ·½Ê½ÃèÊö³ö¼¼ÊõÒªµã£¬Ò²ÊÇÎÒÏ£ÍûµÄ×îÓÐЧÂʵÄ֪ʶ´«²¥·½Ê½¡£
1£® Ò³Ãæ/¿Ø¼þcache
2£® Ó¦ÓóÌÐò¼¶cache
3£® ä¯ÀÀÆ÷¿Í»§¶Ëcache
´ÓʵÏÖ·½Ê½À´¿´£¬ASP.NET CacheÖеÄÒ³Ãæ/¿Ø¼þcacheºÍÓ¦ÓóÌÐò¼¶cache¶¼ÊÇ´æ·ÅÔÚ·þÎñÆ÷ÄÚ´ ......