c#ÖиßЧµÄexcelµ¼ÈësqlserverµÄ·½·¨
±¾ÎÄת×Ô£ºhttp://blog.csdn.net/jinjazz/archive/2008/07/14/2650506.aspx
½«oledb¶ÁÈ¡µÄexcelÊý¾Ý¿ìËÙ²åÈëµÄsqlserverÖУ¬ºÜ¶àÈËͨ¹ýÑ»·À´Æ´½Ósql£¬ÕâÑù×ö²»µ«ÈÝÒ׳ö´í¶øÇÒЧÂʵÍÏ£¬×îºÃµÄ°ì·¨ÊÇʹÓÃbcp£¬Ò²¾ÍÊÇSystem.Data.SqlClient.SqlBulkCopy ÀàÀ´ÊµÏÖ¡£²»µ«Ëٶȿ죬¶øÇÒ´úÂë¼òµ¥£¬ÏÂÃæ²âÊÔ´úÂëµ¼ÈëÒ»¸ö6Íò¶àÌõÊý¾ÝµÄsheet£¬°üÀ¨¶ÁÈ¡£¨È«²¿¶ÁÈ¡±È½ÏÂý£©ÔÚÎҵĿª·¢»·¾³ÖÐÖ»ÐèÒª10Ãë×óÓÒ£¬¶øÕæÕýµÄµ¼Èë¹ý³ÌÖ»ÐèÒª4.5Ãë¡£
using System;
using System.Data;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//²âÊÔ£¬½«excelÖеÄsheet1µ¼Èëµ½sqlserverÖÐ
string connString = "server=localhost;uid=sa;pwd=sqlgis;database=master";
System.Windows.Forms.OpenFileDialog fd = new OpenFileDialog();
if (fd.ShowDialog() == DialogResult.OK)
{
TransferData(fd.FileName, "sheet1", connString);
}
}
public void TransferData(string excelFile, string sheetName, string connectionString)
{
Ïà¹ØÎĵµ£º
ÕâÁ½¸öÊý¾ÝÀàÐÍÊÇÎÒÃÇÔÚѧϰC#ÓïÑԵĹý³ÌÖÐÊý¾Ý±È½ÏÄѵÄÁ½¸öÊý¾ÝÀàÐÍ£¬²»¹ýËûÃǺÜÖØÒª£¬ËùÒÔÓбØÒªÄóöÀ´ËµËµËûÃǵÄʹÓ÷½·¨ºÍ²»Í¬Ö®´¦£¬Ï£Íû¶ÔÄãÓÐËù°ïÖú¡£
ÏÈ×ܵÄÀ´Ëµ£º
ͨ³£ÎÒÃÇÏò·½·¨Öд«µÝµÄÊÇÖµ.·½·¨»ñµÃµÄÊÇÕâЩֵµÄÒ»¸ö¿½±´,È»ºóʹÓÃÕâЩ¿½±´,µ±·½·¨ÔËÐÐÍê±Ïºó,ÕâЩ¿½±´½«±»¶ªÆú,¶øÔÀ´µÄÖµ²»½«Êܵ½Ó°Ïì.´ËÍâÎÒÃÇ ......
ÒòΪ¹¤×÷ÐèÒª£¬Êý¾Ý¿âʹÓõÄMS SQL Server2005£¬¶øĬÈϵÄÅÅÐò¹æÔòÊÇSQL_Latin1_General_CP1_CI_AS¡£´´½¨ÁËÒ»¸ö±í£¬ÒòΪÐèÒª´æ´¢ÖÐÎÄÐÅÏ¢£¬Address×ֶεÄÀàÐÍÊÇnvarchar(255)¡£
´ËʱʹÓÃphpÀ´Á¬½Ósql server£¬Ò³ÃæµÄ±àÂëºÍÎļþµÄ±àÂ붼ÊÇUTF-8£¬²éѯ´ËAddress×ֶΣ¬ÏÔʾÔÚÒ³ÃæÉÏÊÇ???Ö®ÀàµÄ¡£Ôõô½â¾ö£¿
ʹÓÃ
iconv('iso- ......
C#ÖжÔbaseµÄ½âÊÍ(Òý×ÔMSDN):
base ¹Ø¼ü×ÖÓÃÓÚ´ÓÅÉÉúÀàÖзÃÎÊ»ùÀàµÄ³ÉÔ±£º
µ÷ÓûùÀàÉÏÒѱ»ÆäËû·½·¨ÖØдµÄ·½·¨¡£
Ö¸¶¨´´½¨ÅÉÉúÀàʵÀýʱӦµ÷ÓõĻùÀ๹Ô캯Êý¡£
»ùÀà·ÃÎÊÖ»ÄÜÔÚ¹¹Ô캯Êý¡¢ÊµÀý·½·¨»òʵÀýÊôÐÔ·ÃÎÊÆ÷ÖнøÐС£
´Ó¾²Ì¬·½·¨ÖÐʹÓà base ¹Ø¼ü×ÖÊÇ´íÎóµÄ¡£
ÔÚ±¾ÀýÖУ¬»ùÀà Person ºÍÅÉÉúÀà Employee ¶¼ÓÐÒ»¸ö ......
ÏÂÎçÐèÒªÅäÖñ¾»ú°²×°µÄmssqlÊý¾Ý¿âÄܹ»ÔÚÔ¶³Ì·ÃÎÊ£¬ÔÚÍøÉÏËÑË÷µÄ·½·¨£ºhttp://weste.net/2009/5-20/21244518910.html
°´ÕÕÕâ¸ö²½ÖèÒ»²½Ò»²½ÅäÖÃÏÂȥȴ·¢ÏÖÈÔÈ»²»ÄÜ·ÃÎÊ¡£Èç¹ûÅäÖÃprotocolµÄʱºòlisten all ÉèÖÃΪno£¬ÖØÆômssql·þÎñϵͳ»áÌáʾmssql·þÎñ×Ô¶¯Í£Ö¹£»Èç¹ûÉèÖÃΪyes¿ÉÒÔÆô¶¯È´ÔÚnetstatÁбíÖÐÎÞ·¨¼ì²éµ½¶Ô1433¶ ......
xmlpost by HttpWebRequest:
protected string PostXmlToURL(string url,string data)
{
HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create(url);
hwr.Method = "POST";
Stream stream = hwr.GetRequestStream();
StreamWri ......