發表文章

讀取資料庫欄位型態為Image的資料

using (SqlConnection conn = new SqlConnection(connStrdg1)) { conn.Open(); string strSQL = ""; using (SqlCommand command = new SqlCommand()) { command.Connection = conn; command.CommandType = CommandType.Text; strSQL = "SELECT image FROM XXXX WHERE id=@imgid"; command.CommandText = strSQL; command.Parameters.Add("imgid", SqlDbType.UniqueIdentifier).Value = new Guid(Request.QueryString["imgid"].ToString()); //下面這句為主要關鍵所在 Response.ContentType = "image/jpeg"; byte[] image = (byte[])command.ExecuteScalar(); if (image == null) { Response.Redirect("/NoImage.gif"); } else { Response.BinaryWrite(image); } } }

在.cs檔裡動態註冊JavaScript和CSS

//註冊CSS string stylestr = "<style type='text/css'>"; stylestr += ".smallstyle"; stylestr += "{"; stylestr += "font-size: 12px;"; stylestr += "font-family: '新細明體';"; stylestr += "color: Gray;"; stylestr += "}"; stylestr += ".bigbodystyle"; stylestr += "{"; stylestr += "font-size: 20px;"; stylestr += "font-family: '新細明體';"; stylestr += "}"; stylestr += "</style>"; Page.RegisterClientScriptBlock("HideBlock", stylestr);

SQL函數 查詢SQL資料欄位相符的字串

CHARINDEX ( expression1 ,expression2 [ , start_location ] ) 搜尋 expression2 中的 expression1 ,並在找到時傳回它的開始位置。搜尋會在 start_location 開始。 引數 expression1 這是字元 expression ,其中包含要尋找的順序。 expression1 限制為 8000 個字元。 expression2 這是要搜尋的字元運算式。 start_location 這是搜尋開始的整數或 bigint 運算式。如果未指定 start_location ,或者它是負數或 0,搜尋就會從 expression2 開頭開始。

HttpModule與HttpHandler的區別整理

圖片
原本我們在舊版的作業系統上(如XP,Server2003)要讓每個使用者訪問網頁時先進行驗證,判斷是否由外部連結或者是種種的驗證可以直接使用ISAPI來進行(使用C撰寫),但是近年來作業系統的版本已經到了Server2008+,IIS的版本也由原本的IIS6變成了IIS7,因此有些主機在ISAPI的運行變得異常或者是不能執行(但這個問題經過證實是64位元作業系統的問題,變更IIS設定就可以解決這個問題),因此在資料過濾的部份我們除了可以使用ISAPI可以幫我們進行資料過濾,也可運用微軟提供的HttpModule與HttpHandler來處理相同的問題,下面就對者兩者的差異進行說明。

showModalDialog 跳出後背景灰階的語法

圖片
function GridView_OpenDialog2(url, widthpx, heightpx, imgurl) { var dialogcenter = ";dialogTop:" + ((window.screen.height / 2) - (heightpx.replace("px", "") / 2)) + " ; dialogLeft:" + ((window.screen.width / 2) - (widthpx.replace("px", "") / 2)) + ";"; if (imgurl) { var mask = document.createElement("DIV"); mask.id = "GridView_mask"; var style = ""; style += "background-color:white;"; style += "width:100%; height:100%;"; style += "position:fixed; top:0; left:0; zindex:1000;"; style += "filter:alpha(opacity=70); opacity:0.7; zoom:1;-moz-opacity:0.7;"; mask.style.cssText = style; //=======下面這些只有IE支援不建議這樣使用 //mask.style.position = "fixed"; //mask.style.top = 0; //mask.style.left = 0; //mask.style.width = "100%"; ...

Server2008上使用ReportViewer

在Server上面執行ReportViewer會出現找不到物件javascript的錯誤,只要在Web.config加上兩段語法就可以正常執行了

ASP.NET Component 內嵌資源

圖片
在自己寫元件的時候常常需要將一些javascript, 圖片嵌入dll當中,下面兩個網站的教學讓我們可以對於元件開發更快上手 http://support.microsoft.com/kb/910442/zh-tw http://blog.csdn.net/webwalker/archive/2007/09/21/1795376.aspx 另外關於將自己寫好的元件加上ICON圖示也是製作專屬於自己元件的重要過程,下面圖式齒輪狀的是一開始沒有給icon的圖示 http://www.dotblogs.com.tw/jeff377/archive/2008/10/08/5624.aspx http://topic.csdn.net/t/20050222/20/3799032.html

GridView裡面使用Button事件

圖片
我用了微軟的GridView來達成下圖的畫面,在以前使用的習慣是使用Client端的事件再配合javascript來完成資料更新,因此沒有嘗試過Server的事件,這次我直接在ItemTemplate中直接放入一個Button(下圖藍框處)並在RowDateBound中動態加上事件如下,

ReportViewer9.0版 使用前說明

開發前要先安裝Microsoft ReportViewer9.0版(原Visual Studio 2005為8.0版),以下為Download網址 http://www.microsoft.com/downloads/details.aspx?familyID=cc96c246-61e5-4d9e-bb5f-416d75a1b9ef&DisplayLang=en

C# 取得當月份天數

DateTime.DaysInMonth(DateTime.Today.Year,DateTime.Today.Month)

ASP.NET ReportViewr使用方式

string strConnection = ConfigurationManager.ConnectionStrings["ConnectionString2"].ToString(); DataSet myDs = new Report1(); using (SqlConnection conn = new SqlConnection(strConnection)) { conn.Open(); string strSQL = "select * from XXXX"; using (SqlCommand cmd = new SqlCommand(strSQL, conn)) { SqlDataReader myDr = cmd.ExecuteReader(); myDs.Tables["statlist"].Load(myDr); myDr.Close(); myDr.Dispose(); } } //將ReportViewer1的DataSources集合清除 ReportViewer1.LocalReport.DataSources.Clear(); //匯出檔案名稱 ReportViewer1.LocalReport.DisplayName = "XXX彙總表"; //為查看器提供本地報表數據 ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report1.rdlc"); ReportViewer1.LocalReport.DataSources.Add( new Microsoft.Reporting.WebForms.ReportDataSource("Report1_statlist", myDs.Tables["statlist"])); //參數 //ReportParameter param = new ReportParameter("Title", "嗚嗚"); //ReportPara...

ASP.NET動態產生控制項&動態讀取控制項

//動態產生控制項 txt.ID = string.Format("txt{0}", rs["ordetailid"].ToString()); txt.Text = rs["amount"].ToString(); column.Controls.Add(txt); //動態讀取控制項 Page.Request.Form[string.Format("DataList1_statamount$txt{0}", strAmount)].ToString());

win2003 ASP上傳大小限制(轉貼)

問題:WIN2003無法上傳較大的文件「Request 對像 錯誤 \』 ASP 0104 : 80004005 \』 解決方案: 1.先打開IIS管理器: 2.關閉iis admin service服務 找到windows\\system32\\inesrv\\下的metabase.xml, 打開,找到ASPMaxRequestEntityAllowed 把他修改為需要的值, 默認為204800,即200K,把它修改為20480000(20M)。 然後重啟iis admin service服務   二、解決 ASP 無組件上傳錯誤:Request 對像 錯誤 ' ASP   0104   :   80004005 ' 不許操作---2003 server

抓取QueryString上字串(參數)

//假設URL參數字串為 //index.aspx?id=aaa&email=hh@gmail.com&id2=bbb&email=cc@hotmail.com for (int i = 0; i < Page.Request.QueryString.Count; i++) { if (Page.Request.QueryString.AllKeys.GetValue(i).ToString().StartsWith("id")) { rowid = Page.Request.QueryString.AllKeys.GetValue(i).ToString().Replace("id", ""); if (strParameter == "") { if (!string.IsNullOrEmpty(rowid)) strIndex += rowid; strParameter = " ( id=" + string.Format("@id{0} ", rowid) + " and email=" + string.Format("@email{0} ", rowid) + " ) "; } else { if (!string.IsNullOrEmpty(rowid)) strIndex += "," + rowid; strParameter += " OR ( id=" + string.Format("@id{0} ", rowid) + " and email=" + string.Format("@email{0} ", rowid) + " ) "; } } }

Java 取得常用的環境變數

//取得當前路徑的方法 String curDir = System.getProperty("user.dir"); 另外下面是一些常用的環境變數

同時載入SQL2000和SQL2005的JDBC發生錯誤

當您載入 SQL Server 2000 驅動程式 JDBC 的 SQL Server 2005 的驅動程式 JDBC 的在同一個應用程式中,您嘗試連線到 SQL Server 2005 資料庫,再執行查詢,您可能會收到錯誤訊息 如果要解決這個問題而定,請依照下列步驟執行: 

Java 存取 MSSQL2005 資料庫

java 連接 sql 2005 的方法: 1。到微軟官方網站下載2005的jdbc並解壓,獲得文件sqljdbc.jar Microsoft SQL Server 2005 JDBC Driver 1.2 2。複製文件sqljdbc.jar到jdk目錄\jdk1.5\jre\lib\ext下。 3。開始-〉所有程式-〉sql server 2005-〉組態工具-〉SQL Server Configuration Manager。啟動sql 2005服務。點選 sql server2005網絡組態,並選中」MSSQLserver的協定,啟用tcp/ip協定。

使用JavaScript取得網址列資訊

圖片
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write ( unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E" ) );

Visual Studio 2005使用AJAX 出現Sys 未被定義

在Visual Studio 2008裡使用AJAX並不會有這樣的問題,但是Visual Studio 2005就會出現異常的情況,而此種異常狀況主要的原因是在web.config裡面必須加入下面的語法即可解決 <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules> <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </modules> <handlers> <remove name="WebServiceHandlerFactory-Integrated"/> <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integr...

ASP Request 抓值

Request.Servervariables("PATH_INFO") ==> '取得目前頁面路徑,如:/Exam/main.asp Request.Servervariables("Script_Name") ==> '取得目前頁面路徑,如:/Exam/main.asp Request.Servervariables("PATH_TRANSLATED") ==> '取得實體路徑,如:D:/sss/exa/main.asp Request.Servervariables("SERVER_NAME") ==> '取得Server主機名稱 Request.Servervariables("SERVER_PORT") ==> '取得目前網頁通訊Port Resqest.ServerVariables("Http_Accept_Language") ==> 'IE瀏覽器語系,如en-US,zh-tw;q=0.5

CMD下FTP使用命令全集

FTP命令是Internet用戶使用最頻繁的命令之一,不論是在DOS還是UNIX操作系統下使用FTP,都會遇到大量的FTP內部命令。熟悉並靈活應用FTP的內部命令,可以大大方便使用者,並收到事半功倍之效。 FTP的命令行格式為: ftp -v -d -i -n -g [主機名] -v 顯示遠程服務器的所有響應信息; -n 限制ftp的自動登錄,即不使用; .n etrc文件; -d 使用調試方式; -g 取消全局文件名。

取消Vista & Server 2008安裝軟體提示

使用 Windows Vista 其中最令人不習慣的事,就是 Vista 在使用者做一些動作時,經常會跳出警告或要求確認的畫面,雖然這是為了系統安全,不過還是令人感到非的煩, 底下提供如何從系統中移除使用者帳戶控制(UAC)

Server 2008 無線網路無法啟用

請試想下列案例。 您有的電腦,正在執行 Windows Server 2008 上,且,在有安裝無線網路介面卡。 未安裝無線 LAN 服務功能。 在這種情況下,您可能會遇到下列徵狀: 在 [ 網路連線] 組態] 對話方塊中,無線網路連線的狀態是 「 停用 」。 如果您無線網路連線圖示上按一下滑鼠右鍵,然後按一下 [ 啟用 ,[ 無線網路連線 對話 」 方塊就會出現,並表示已啟用連線。 不過,在 [ 網路連線 ] 對話方塊中,無線網路連線仍然似乎停用。 請注意 在 [裝置管理員] 中,無線介面卡驅動程式的狀態為啟用"。

javascript比較日期大小

將兩個物件傳入下面的函數就可得到時間的大小,可視情況自行修改 function checkDate(obj1, obj2) { var d1 = obj1.value; var d2 = obj2.value; //d1 = d1.replace(/-/g, "/"); //d2 = d2.replace(/-/g, "/"); //======str.repalce(/-/g, "/"); g 代表替換str字串中全部"-"為"/" d1 = new Date(d1); d2 = new Date(d2); var times = d2.getTime() - d1.getTime(); var days = parseInt(times / (1000 * 60 * 60 * 24)); //return (days

Access 使用 like 語法造成 記憶體不足

目前找到的原因:大多是使用like語法,所造成的。 下面紅色字體部份改成藍色字體部份就可以解決這樣的問題 strSql = "select * from Info where name like '%" + txtSearch.Text + "%' or note like '%" + txtSearch.Text + "%' order by autocount desc"; strSql = "select * from Info where InStr(1,LCase(name),LCase(\'" + txtSearch.Text + "\'),0) <> 0 or InStr(1,LCase(note),LCase(\'" + txtSearch.Text + "\'),0) <> 0 order by autocount desc";