2009年6月9日 星期二

Asp.net RSS TOOLKIT

http://demo.tc/view.aspx?id=446

T-SQL Convert

convert(想變成的型別,那個欖位)

2009年6月4日 星期四

Orcale Trunc(date)函數

trunc ( date, [ format ] )

取時間中的日期

可參考

http://kuanglian2000.wordpress.com/2006/12/18/oracle-function時間只取時間中的日期或時間

Orcale NVL()函數

NVL(COMM, 0)
如 果 COMM 是 NULL , 就 傳 回 0 , 否 則 傳 回 COMM

Vb.net cmd.Parameters.AddWithValue(Insert資料庫)

Imports System.Data.SqlClient
Try
Using conn As New SqlConnection(strConn)
Using cmd As New SqlCommand("Insert into product(productName,)Values(@123,)", conn)
conn.Open()
cmd.Parameters.AddWithValue("@123", Me.TextBox1.Text)
cmd.ExecuteNonQuery()
End Using
End Using
Catch ex As Exception
MsgBox(ex.Message)
End Try

Asp.net Connection String 寫法

使用Sql Server 驗證
Data Source=.;Initial Catalog=Northwind;User ID=sa;Password=123

使用Windows驗證
Data Source=.;Initial Catalog=Northwind;Integrated Security=True

Data Source資料來源
Initial Catalog要連結的資料庫
User ID使用者名稱Password密碼
Integrated Security=True(使用Windows驗證登入)

web.config


Sql驗證

<connectionStrings>
<add name="DBConnectionString" connectionString="Data Source=.;Initial Catalog=abc;User ID=sa;Password=abc" providerName="System.Data.SqlClient" />
</connectionStrings>

windows驗證

<add name="DBConnectionString" connectionString="data source=.;initial catalog=ShuLong;integrated security=true;"/>


.cs裡

using System.Configuration;//抓Web.config用

string Conn = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;

Vb.net System.Threading(抓取電腦中的語系)

Imports System.Threading
Me.Label1.Text =Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageNameMe.Label2.Text = Thread.CurrentThread.CurrentUICulture.NativeNameMe.Label3.Text = Thread.CurrentThread.CurrentCulture.NativeName

Asp.net GridView(匯出成各種格式)

Protected Sub 匯出Word(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.GridView1.AllowSorting = False
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=" & Me.HiddenField1.Value & ".doc")
Response.ContentType = "application/vnd.ms-word"
Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
Response.Write("")
GridView1.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString)
Response.End()
End Sub

Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
'處理'GridView' 的控制項 'GridView' 必須置於有 runat=server 的表單標記之中
End Sub

AutoEventWireup="false" EnableEventValidation="false"

Asp.net Response.ContentType(輸出的所有類型)

ez=application/andrew-inset hqx=application/mac-binhex40 cpt=application/mac-compactpro doc=application/msword bin=application/octet-stream dms=application/octet-stream lha=application/octet-stream lzh=application/octet-stream exe=application/octet-stream class=application/octet-stream so=application/octet-stream dll=application/octet-stream oda=application/oda pdf=application/pdf ai=application/postscript eps=application/postscript ps=application/postscript smi=application/smil smil=application/smil mif=application/vnd.mif xls=application/vnd.ms-excel ppt=application/vnd.ms-powerpoint wbxml=application/vnd.wap.wbxml wmlc=application/vnd.wap.wmlc wmlsc=application/vnd.wap.wmlscriptc bcpio=application/x-bcpio vcd=application/x-cdlink pgn=application/x-chess-pgn cpio=application/x-cpio csh=application/x-csh dcr=application/x-director dir=application/x-director dxr=application/x-director dvi=application/x-dvi spl=application/x-futuresplash gtar=application/x-gtar hdf=application/x-hdf js=application/x-javascript skp=application/x-koan skd=application/x-koan skt=application/x-koan skm=application/x-koan latex=application/x-latex nc=application/x-netcdf cdf=application/x-netcdf sh=application/x-sh shar=application/x-shar swf=application/x-shockwave-flash sit=application/x-stuffit sv4cpio=application/x-sv4cpio sv4crc=application/x-sv4crc tar=application/x-tar tcl=application/x-tcl tex=application/x-tex texinfo=application/x-texinfo texi=application/x-texinfo t=application/x-troff tr=application/x-troff roff=application/x-troff man=application/x-troff-man me=application/x-troff-me ms=application/x-troff-ms ustar=application/x-ustar src=application/x-wais-source xhtml=application/xhtml+xml xht=application/xhtml+xml zip=application/zip au=audio/basic snd=audio/basic mid=audio/midi midi=audio/midi kar=audio/midi mpga=audio/mpeg mp2=audio/mpeg mp3=audio/mpeg aif=audio/x-aiff aiff=audio/x-aiff aifc=audio/x-aiff m3u=audio/x-mpegurl ram=audio/x-pn-realaudio rm=audio/x-pn-realaudio rpm=audio/x-pn-realaudio-plugin ra=audio/x-realaudio wav=audio/x-wav pdb=chemical/x-pdb xyz=chemical/x-xyz bmp=image/bmp gif=image/gif ief=image/ief jpeg=image/jpeg jpg=image/jpeg jpe=image/jpeg png=image/png tiff=image/tiff tif=image/tiff djvu=image/vnd.djvu djv=image/vnd.djvu wbmp=image/vnd.wap.wbmp ras=image/x-cmu-raster pnm=image/x-portable-anymap pbm=image/x-portable-bitmap pgm=image/x-portable-graymap ppm=image/x-portable-pixmap rgb=image/x-rgb xbm=image/x-xbitmap xpm=image/x-xpixmap xwd=image/x-xwindowdump igs=model/iges iges=model/iges msh=model/mesh mesh=model/mesh silo=model/mesh wrl=model/vrml vrml=model/vrml css=text/css html=text/html htm=text/html asc=text/plain txt=text/plain rtx=text/richtext rtf=text/rtf sgml=text/sgml sgm=text/sgml tsv=text/tab-separated-values wml=text/vnd.wap.wml wmls=text/vnd.wap.wmlscript etx=text/x-setext xsl=text/xml xml=text/xml mpeg=video/mpeg mpg=video/mpeg mpe=video/mpeg qt=video/quicktime mov=video/quicktime mxu=video/vnd.mpegurl avi=video/x-msvideo movie=video/x-sgi-movie ice=x-conference/x-cooltalk

Asp.net DataBinder.Eval(針對物件剖析並評估資料繫結運算式)

使用反映在 Run Time 時針對物件剖析並評估資料繫結運算式。
Eval(Object, String)
在執行階段評估資料繫結運算式。
Eval(Object, String, String)
在執行階段評估資料繫結運算式,並將結果格式化為字串。參考資料http://msdn.microsoft.com/zh-tw/library/system.web.ui.databinder.eval.aspx

Asp.net Server.UrlEncode(可預防網址被截段)

說明

將字串作 URL 編碼,並傳回編碼的字串

作用

如網址字串中可能有空格或是特殊字元時可用

範例

Dim MyURL As String
MyURL = "http://www.contoso.com/articles.aspx?title=" & trim(Server.UrlEncode("ASP.NET Examples"))
Response.Write( " ASP.NET Examples ")

Office EXCEL下拉選單

1.建立下拉格中需要的資料>選取資料>插入>名稱>定義>給那些表格一個定義的名稱
2.再要下拉的格子中>驗證>儲存格內允許-清單>來源輸入=定義的名稱
可參考的含數
//OFFSET算出的參照位址,可以是單一個儲存格或一個儲存格範圍OFFSET(要撈出的開始格,向右或向左欖位,向上或向下欖位,下多少欖位,右多少欖位
//MATCH抓媒合的值MATCH(為要找的值,儲存格範圍,1為等於或僅次於要找的值0完全等於-1等於或大於)
//COUNTA計算不是空白的儲存格"數量"COUNTA([範圍,條件值)
//COUNTIF計算某範圍內符合某搜尋準則的儲存格個數COUNTIF((範圍,條件值)

Office Word文件保護(可選擇保護章節)

1.插入>分節符號類型>選擇要分節的
2.工具>保護文件>僅允許在文件中使用此類型的編輯方式打勾>選取章節(選擇要的章節)
3.是,開始強制保護

1.右鍵將表單打開
2.就可以選各類型當強制保護時還可以編輯