½«ExcelÎļþÊý¾Ý¿âµ¼ÈëSQL ServerµÄÈýÖÖ·½°¸
½«ExcelÎļþÊý¾Ý¿âµ¼ÈëSQL ServerµÄÈýÖÖ·½°¸
//·½°¸Ò»£º ͨ¹ýOleDB·½Ê½»ñÈ¡ExcelÎļþµÄÊý¾Ý£¬È»ºóͨ¹ýDataSetÖÐתµ½SQL Server
openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Excel files(*.xls)|*.xls";
if(openFileDialog.ShowDialog()==DialogResult.OK)
{
FileInfo fileInfo = new FileInfo(openFileDialog.FileName);
string filePath = fileInfo.FullName;
string connExcel = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=Excel 8.0";
try
{
OleDbConnection oleDbConnection = new OleDbConnection(connExcel);
oleDbConnection.Open();
//»ñÈ¡excel±í
DataTable dataTable = oleDbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
//»ñÈ¡sheetÃû£¬ÆäÖÐ[0][1]...[N]: °´Ãû³ÆÅÅÁÐµÄ±íµ¥ÔªËØ
string tableName = dataTable.Rows[0][2].ToString().Trim();
tableName = "[" + tableName.Replace("'","") + "]";
//ÀûÓÃSQLÓï¾ä´ÓExcelÎļþÀï»ñÈ¡Êý¾Ý
//string query = "SELECT classDate,classPlace,classTeacher,classTitle,classID from " + tableName;
string query = "SELECT ÈÕÆÚ,¿ª¿Î³ÇÊÐ,½²Ê¦,¿Î³ÌÃû³Æ,³ÖÐøʱ¼ä from " + tableName;
dataSet = new DataSet();
//OleDbCommand oleCommand = new OleDbCommand(query, oleDbConnection);
//OleDbDataAdapter oleAdapter = new OleDbDataAdapter(oleCommand);
Ïà¹ØÎĵµ£º
CREATE DATABASE
´´½¨Ò»¸öÐÂÊý¾Ý¿â¼°´æ´¢¸ÃÊý¾Ý¿âµÄÎļþ£¬»ò´ÓÏÈÇ°´´½¨µÄÊý¾Ý¿âµÄÎļþÖи½¼ÓÊý¾Ý¿â¡£
˵Ã÷ ÓйØÓë DISK INIT Ïòºó¼æÈÝÐԵĸü¶àÐÅÏ¢£¬Çë²Î¼û"Microsoft® SQL Server™ Ïòºó¼æÈÝÐÔÏêϸÐÅÏ¢"ÖеÄÉ豸£¨¼¶±ð 3£©¡£
Óï·¨
CREATE DATABASE database_name
[ ON
[ < filespec > ......
ÏÖÒªÇó²éѯ½çÃ棺²»ÂÛ15λ»òÕß18λÉí·ÝÖ¤ºÅ¶¼Äܲéѯ³öÊý¾Ý¿âÖÐËùÓе±Ç°Óû§ÐÅÏ¢¡£
·½°¸1£º
create or replace function CONVERT_ID_15 (/*ת»»Éí·ÝÖ¤ºÅΪ15λ*/
p_id2 in varchar2
) return varchar2
is
p_id varchar2(20);
id varchar2(15);
begin
p_id:=ltrim(p_id2);
p_id ......
1 windowsµÇ¼ÕË»§¿Ú£ºEXEC ap_grantlogin 'windowsÓòÃû\ÓòÕË»§'
2 SQL µÇ¼ÕË»§:EXEC sp_addlogin 'ÕË»§Ãû','ÃÜÂë'
3 ´´½¨Êý¾Ý¿âÓû§:exec spgrantdbaccess 'µÇ¼ÕË»§','Êý¾Ý¿âÓû§'
¶þ ¸øÊý¾Ý¿âÓû§ÊÚȨ
grant ȨÏÞ on ±íÃû to Êý¾Ý¿âÓû§ ......
sql×¢È룬ËùνSQL×¢È룬¾ÍÊÇͨ¹ý°ÑSQLÃüÁî²åÈëµ½Web±íµ¥µÝ½»»òÊäÈëÓòÃû»òÒ³ÃæÇëÇóµÄ²éѯ×Ö·û´®£¬×îÖÕ´ïµ½ÆÛÆ·þÎñÆ÷Ö´ÐжñÒâµÄSQLÃüÁ±ÈÈçÏÈÇ°µÄºÜ¶àÓ°ÊÓÍøվй¶VIP»áÔ±ÃÜÂë´ó¶à¾ÍÊÇͨ¹ýWEB±íµ¥µÝ½»²éѯ×Ö·û±©³öµÄ£¬ÕâÀà±íµ¥ÌرðÈÝÒ×Êܵ½SQL×¢Èëʽ¹¥»÷£®
¡¡¡¡µ±Ó¦ÓóÌÐòʹÓÃÊäÈëÄÚÈÝÀ´¹¹Ô춯 ......
»ùÓÚSQL Server ·ÖÒ³´æ´¢¹ý³ÌµÄÑݽø ÊÕ²Ø
Õë¶ÔÊý¾Ý¿âÊý¾ÝÔÚUI½çÃæÉϵķÖÒ³ÊÇÀÏÉú³£Ì¸µÄÎÊÌâÁË£¬ÍøÉϺÜÈÝÒ×ÕÒµ½¸÷Ö֓ͨÓô洢¹ý³Ì”´úÂ룬¶øÇÒÓÐЩ»¹¶¨ÖƲéѯÌõ¼þ£¬¿´ÉÏȥʹÓúܷ½±ã¡£±ÊÕß´òËãͨ¹ý±¾ÎÄÒ²À´¼òµ¥Ì¸Ò»Ï»ùÓÚSQL SERVER 2000µÄ·ÖÒ³´æ´¢¹ý³Ì£¬Í¬Ê±Ì¸Ì¸SQL SERVER 2005Ï·ÖÒ³´æ´¢¹ý³ÌµÄÑ ......