|
<% Set msg = Server.CreateObject("JMail.Message") msg.silent = true msg.Logging = true msg.Charset = "gb2312" msg.MailServerUserName = "*****@126.com" ''ÊäÈësmtp·þÎñÆ÷ÑéÖ¤µÇ½Ãû £¨ÓʾÖÖÐÈκÎÒ»¸öÓû§µÄEmailµØÖ·£© msg.MailServerPassword = "*****" ''ÊäÈësmtp·þÎñÆ÷ÑéÖ¤ÃÜÂë £¨Óû§EmailÕʺŶÔÓ¦µÄÃÜÂ룩 msg.From ="*****@126.com"' Request.Form("email") ''·¢¼þÈËEmail msg.FromName = "С»Ò"'Request.Form("name") ''·¢¼þÈËÐÕÃû msg.AddRecipient "*****@163.com" ''ÊÕ¼þÈËEmail msg.Subject = "ÐżþÖ÷Ìâ"'Request.Form("subject") ''ÐżþÖ÷Ìâ msg.Body = "ÕýÎÄ"'Request.Form("body") ''ÕýÎÄ 'msg.addattachment(server.mappath("new.txt")) msg.Send ("smtp.126.com") ''smtp·þÎñÆ÷µØÖ·£¨ÆóÒµÓʾֵØÖ·£© set msg = nothing response.write("·¢Ëͳɹ¦£¡") %>Top
不好意思,重發(fā)一次: <% Set msg = Server.CreateObject("JMail.Message") msg.silent = true msg.Logging = true msg.Charset = "gb2312" msg.MailServerUserName = "*****@126.com" ''輸入smtp服務(wù)器驗證登陸名 (郵局中任何一個用戶的Email地址) msg.MailServerPassword = "*****" ''輸入smtp服務(wù)器驗證密碼 (用戶Email賬號對應的密碼) msg.From ="*****@126.com"' Request.Form("email") ''發(fā)件人Email msg.FromName = "小灰"'Request.Form("name") ''發(fā)件人姓名 msg.AddRecipient "*****@163.com" ''收件人Email msg.Subject = "信件主題"'Request.Form("subject") ''信件主題 msg.Body = "正文"'Request.Form("body") ''正文 'msg.addattachment(server.mappath("new.txt")) msg.Send ("smtp.126.com") ''smtp服務(wù)器地址(企業(yè)郵局地址) set msg = nothing response.write("發(fā)送成功!") %>Top
'本地提交 Function isLocalPost() server1 = CStr(request.servervariables("http_referer")) server2 = CStr(request.servervariables("server_name")) isLocalPost = true If Mid(server1, 8, Len(server2))<>server2 Then isLocalPost = false End If End Function '訪問者IP Function ip() ip = request.servervariables("http_x_forwarded_for") If ip = "" Then ip = request.servervariables("remote_addr") End If End FunctionTop
excel導入導出: 1 excel導放到數(shù)據(jù)庫 select * into SQL中的表 from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0', 'Data Source="e:\excel\tt.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$] 二:數(shù)據(jù)庫導入到excel EXEC master..xp_cmdshell 'bcp 庫名.dbo.表名 out f:\1.xls -c -q -t, -S"服務(wù)器名" -U"用戶名" -P"密碼"' 三,插入記錄到已有的excel中 1\如何從第十一行開始追加記錄? 2\是否可以采用EXCEL的默認列,如"A:B:C:D"等來代替列名? --1.你可以在Excel表的第10行隨便填一個數(shù)據(jù),保證Excel表中,第10行至少有一個數(shù)據(jù),10行之后沒有數(shù)據(jù),這樣你可以用類似下面的語句插入數(shù)據(jù)到Excel表中,可以保證數(shù)據(jù)插入在11行開始追加 insert into OPENROWSET('MICROSOFT.JET.OLEDB.4.0' ,'Excel 5.0;HDR=NO;DATABASE=c:\test.xls',Sheet1$)(F1,F2) select * from 表 --2.如果你的列中是有數(shù)據(jù)的,可以用F1~Fn來代替列名 EG:insert into OPENROWSET('MICROSOFT.JET.OLEDB.4.0' ,'Excel 5.0;HDR=NO;DATABASE=f:\book1.xls',Sheet1$)(f1,f2,f3,f4,f5,f6,f7) select manage_id,manage_name,manage_password,manage_rank,manage_regtime,manage_frontip,manage_fronttime from manage 四:插入到excel insert into OpenDataSource( 'Microsoft.Jet.OLEDB.4.0','Data Source="f:book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0') ...[sheet1$](Code,name) VALUES ('20', 'Test')
下面的是用一個標準的文本文件的內(nèi)容創(chuàng)建一個數(shù)據(jù)表 ***********鄒建(access數(shù)據(jù)庫)********************************************************************************************** --如果你要在sql中指定字段分隔符,則要寫格式文件,無法在openrowset中指定字段分隔符 導入文本文件時如何指定字段類型? =========================================================================== 問題: 我有一個文本文件需要導入 Access ,但是文本文件中有一列數(shù)據(jù)原本是文本, 但是導入數(shù)據(jù)庫后自動變成了“雙精度”類型,我該如何讓各個字段按我需要的 數(shù)據(jù)類型生成哪? 如何讓 ACCESS 按照我規(guī)定的構(gòu)架、規(guī)格從文本文件、XLS文檔中導入數(shù)據(jù)? ========================================================================== 方法: 用 Schema.ini 文件 作用:Schema.ini用于提供文本文件中記錄的構(gòu)架信息。 每個 Schema.ini 項都用于指定表的五個特征之一: 1、文本文件名 2、文件格式 3、字段名、字段長度、字段類型 4、字符集 5、特別數(shù)據(jù)類型轉(zhuǎn)換 ====================================================================== 指定文件名 文件名要用方括號括起來,例如如果要對 Sample.txt 使用數(shù)據(jù)構(gòu)架信息文件, 那么它的對應的項應該是 [Sample.txt] ======================================================================= 指定文件格式 格式說明 表格式 Schema.ini 格式描述 Tab 制表符分隔 文件中的字段用制表符分隔 Format=TabDelimited CSV 分隔 文件中的字段用逗號來分隔 Format=CSVDelimited 自定義分隔 文件中的字段可以用任何字符 Format=Delimited(自定義分隔符) 來分隔,所有的字符都可以 用來分隔,包括空格,但是 雙引號 ( " ) 除外 - 或者沒有分隔符 - Format=Delimited( ) 固定寬度 文件中的字段為固定長度 =============================================================== 指定字段 你可以有兩種方法在一個字符分隔的文本文件中指定字段名 1、在文本文件中的第一行包含字段名,并且設(shè)置 ColNameHeader 為 True 。 2、用數(shù)字編號指定每一列并且指定每一列的名字以及數(shù)據(jù)類型 你必須用數(shù)字編號指定每一列并且指定每一列的名字、數(shù)據(jù)類型以及長度 (在固定長度分隔的文本文件中需要指定長度) 注意,設(shè)定了 ColNameHeader 選項,在 Schema.ini 中 Windows 注冊時會忽略 FirstRowHasNames 選項。 你也可以指定字段的數(shù)據(jù)類型,使用 MaxScanRows 選項用來指定在確定列的 數(shù)據(jù)類型時要掃描多少行數(shù)據(jù)。設(shè)置 MaxScanRows 為 0 將掃描整個文件。 如果文本文件第一行包含字段名,并且要掃描整個文件,改項目就要定義如下: ColNameHeader=True MaxScanRows=0 接下來的項目用來指定表中的字段,使用列編號(Coln)選項來指定列。字段長度在 “固定分隔文本文件中”是必填項目,在“字符分隔文本文件”中是可選項目。 示例:定義 2 個字段,CustomerNumber 是長度為 10 的文本字段、 CustomerName 是長度為 30 的文本字段。 Col1=CustomerNumber Text Width 10 Col2=CustomerName Text Width 30 語法如下: Coln=ColumnName type [Width #] 參數(shù)解釋如下: 參數(shù) 說明 ColumnName 文本,標識字段名,如果包含空格要用雙引號括起來 type 數(shù)據(jù)類型包括: Microsoft Jet 數(shù)據(jù)類型:Bit Byte Short Long Currency Single Double DateTime Text Memo ODBC 數(shù)據(jù)類型: Char (same as Text) Float (same as Double) Integer (same as Short) LongChar (same as Memo) Date date format 其中date format 是日期的格式字符串例如:Date YYYY-MM-DD Width 字符串的長度,后面的數(shù)字用來指定字段的長度(“固定分隔文本文件”為必填, “文字分隔文本文件”為可選) # 整形數(shù)字,標識字段長度 =================================================================== 指定字符集 CharacterSet 項有兩個選擇:ANSI | OEM 選擇 ANSI 字符集用如下方法: CharacterSet=ANSI ==================================================================== 特別數(shù)據(jù)類型轉(zhuǎn)換 特別數(shù)據(jù)類型轉(zhuǎn)換主要是定義比如日期、貨幣型數(shù)據(jù)如何轉(zhuǎn)換或者如何顯示的, 你可以參考下面這張表: 選項 說明 DateTimeFormat Can be set to a format string indicating dates and times. You should specify this entry if all date/time fields in the import/export are handled with the same format. All Microsoft Jet formats except A.M. and P.M. are supported. In the absence of a format string, the Windows Control Panel short date picture and time options are used. DecimalSymbol Can be set to any single character that is used to separate the integer from the fractional part of a number. NumberDigits Indicates the number of decimal digits in the fractional portion of a number. NumberLeadingZeros Specifies whether a decimal value less than 1 and greater than -1 should contain leading zeros; this value can either be False (no leading zeros) or True. CurrencySymbol Indicates the currency symbol to be used for currency values in the text file. Examples include the dollar sign ($) and Dm. CurrencyPosFormat Can be set to any of the following values: · Currency symbol prefix with no separation ($1) · Currency symbol suffix with no separation (1$) · Currency symbol prefix with one character separation ($ 1) · Currency symbol suffix with one character separation (1 $) CurrencyDigits Specifies the number of digits used for the fractional part of a currency amount. CurrencyNegFormat Can be one of the following values: · ($1) · -$1 · $-1 · $1- · (1$) · -1$ · 1-$ · 1$- · -1 $ · -$ 1 · 1 $- · $ 1- · $ -1 · 1- $ · ($ 1) · (1 $) This example shows the dollar sign, but you should replace it with the appropriate CurrencySymbol value in the actual program. CurrencyThousandSymbol Indicates the single-character symbol to be used for separating currency values in the text file by thousands. CurrencyDecimalSymbol Can be set to any single character that is used to separate the whole from the fractional part of a currency amount. ==================================================================== 下面給出一個簡單的例子,假設(shè)有一個表Contacts.txt類似下面: 姓名 單位 聯(lián)系日期 王海 上海有機化學研究所 2002-1-1 羅炙 數(shù)字化機床研究院 2004-1-1 導入 Access 應該類似下面表格: 姓名 單位 聯(lián)系日期 王海 上海有機化學研究所 2002-1-1 羅炙 數(shù)字化機床研究院 2004-1-1 那么 Schema.ini 則是類似下面的INI文件: [Contacts.txt] ColNameHeader=True format=Delimited( )‘此處表示為用空格作分界符,如果是用分號的話則為:format=Delimited(;) MaxScanRows=0 CharacterSet=ANSI Col1="姓名" Char Width 10 Col2="單位" Char Width 9 Col3="聯(lián)系日期" Date Width 8 注釋如下: [Contacts.txt] ///文本文件名 ColNameHeader=True ///帶有表頭 format=Delimited( ) ///空格作為分隔符,如果是分號,請用format=Delimited(;) 來解決 MaxScanRows=0 ///掃描整個文件 CharacterSet=ANSI ///ANSI 字符集 Col1="姓名" Char Width 10 ///字段1 Col2="單位" Char Width 9 ///字段2 Col3="聯(lián)系日期" Date Width 8 ///字段3 ///如果有更多字段可 Col4 .... ColN 注意,Schema.ini 必須和需要導入的文本文件在同一目錄。 此后,我們就可以利用下面的語句來導入數(shù)據(jù)了: CurrentProject.Connection.Execute "SELECT * INTO NewContact FROM [Text;FMT=Delimited;HDR=Yes;DATABASE=C:\;].[Contacts#txt];"T
完整示例(有移動,增加,刪除) <SCRIPT LANGUAGE="JScript"> function se(se_text,se_value) { var oOption = document.createElement("OPTION"); oOption.text=se_text; oOption.value=se_value; addselect.add(oOption); } function cha(add_text,add_value) { var oOption = document.createElement("OPTION"); oOption.text=add_text; oOption.value=add_value; addselect.add(oOption); } function del(se_index) { addselect.remove(se_index); } </SCRIPT> <SELECT ID="oSelect" NAME="Cars" SIZE="13" ondblclick="cha (this.options[this.selectedIndex].text,this.value);"> <OPTION VALUE="1" SELECTED>寶馬 <OPTION VALUE="2">保時捷 <OPTION VALUE="3" >奔馳 </SELECT> ===> <select name="addselect" SIZE="13" ondblclick="del(this.selectedIndex);"> </select> <input name="se1" type="text" value="f" > <input name="se2" type="text" value="2"> <input type="button" name="Submit" value="增加" onclick="se(se1.value,se2.value);">
call downloadFile(Request("path")) function downloadFile(strFile) strFilename = server.MapPath(strFile) Response.Buffer = True Response.Clear Set s = Server.CreateObject("ADODB.Stream") s.Open s.Type = 1 on error resume next Set fso = Server.CreateObject("Scripting.FileSystemObject") if not fso.FileExists(strFilename) then Response.Write("<h1>Error:</h1>" & strFilename & " does not exist<p>") Response.End end if Set f = fso.GetFile(strFilename) intFilelength = f.size s.LoadFromFile(strFilename) if err then Response.Write("<h1>Error: </h1>" & err.Description & "<p>") Response.End end if Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name Response.AddHeader "Content-Length", intFilelength Response.CharSet = "UTF-8" Response.ContentType = "application/octet-stream" Response.BinaryWrite s.Read Response.Flush s.Close Set s = Nothing End Function
|