Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Parameter Queries in ASP.NET with MS Access

Parameter Queries in ASP.NET with MS Access
A selection of code samples for executing queries against MS Access using parameters.
Making use of the ASP.NET 2.0 datasource controls is fine, but it is important to understand how to manually create data access code. Best practice dictates that, at the very least, parameters are used to represent values that are passed into the SQL to be executed, rather than un-sanitised values straight from the user. The main reason for this cannot be over-emphasised in terms of its importance - it protects the application against SQL Injection attacks. In addition, parameters do not require delimiters. Therefore there is no need to worry about octothorpes (#) or apostrophes for dates, or doubling single quotes in strings.
These samples all assume that the values being passed into the parameters have been properly validated for datatype, existence, range etc, according to the business rules for the application. The serverside validation code is not included, as it will differ from app to app, and is not the focus of these samples anyway. However, it is important to stress that all user input must be validated server-side before being included in a SQL statement. Better to reject it outright, rather than have to unpick rubbish that pollutes the database...
The required components are an OleDbConnection object, a ConnectionString property, an OleDbCommand object and an OleDbParameterCollection. These all reside in the System.Data.OleDb namespace, which needs to be referenced. Also, the connection string is held in the Web.Config, and a static method GetConnString() has been created in a class called Utils (also static) to retrieve it:
[C#]
public static string GetConnString()
{
return WebConfigurationManager.ConnectionStrings["myConnStr"].ConnectionString;
}

[VB]
Public Shared Function GetConnString() As String
Return WebConfigurationManager.ConnectionStrings("myConnStr").ConnectionString
End Function

 
Fo


Ïà¹ØÎĵµ£º

40ÌõASP.NET¿ª·¢Tip

2010-01-25 14:24
40ÌõASP.NET¿ª·¢Tip
×÷Õߣº÷è÷ë   À´Ô´£º²©¿ÍÔ°   ·¢²¼Ê±¼ä£º2010-01-21 13:16   ÔĶÁ£º287 ´Î  Ô­ÎÄÁ´½Ó   [ÊÕ²Ø]  
1¡¢ÔÚcompilation Ï£¬ÇëÉèÖÃdebug=false £¬ÈçÏ£º
default Language="c#" debug="false">
2¡¢ÇëʹÓÃServer.Tran ......

ASP.NET³£ÓÃÓï¾ä

1.//µ¯³ö¶Ô»°¿ò.µã»÷תÏòÖ¸¶¨Ò³Ãæ
Response.Write(" <script>window.alert('¸Ã»áԱûÓÐÌá½»ÉêÇë,ÇëÖØÐÂÌá½»£¡')
</script>");
Response.Write(" <script>window.location
='http://www.51aspx.com/bizpulic/upmeb.aspx' </script>");
2.//µ¯³ö¶Ô»°¿ò
Response.Write(" <script lang ......

WCFÖеķþÎñºÍASP.NET AJAXÖеÄWebService

WCFµÄ¼Ü¹¹£ºusing System.ServiceModel;
ÆõÔ¼:Contract
[ServiceContract]
public partial interface IContract
{
        [OperationContract]
        string DocumentWebHostUrl();
}
·þÎñ£ºService
[ServiceBehavior(IncludeException ......

ÈÏʶASP.NETÅäÖÃÎļþWeb.config


ÈÏʶASP.NETÅäÖÃÎļþWeb.config
×÷ÕߣºSabine¡¡À´Ô´£ºÈüµÏÂÛ̳
¡¡¡¡Ò»¡¢ÈÏʶWeb.configÎļþ
Web.configÎļþÊÇÒ»¸öXMLÎı¾Îļþ£¬ËüÓÃÀ´´¢´æ ASP.NET Web Ó¦ÓóÌÐòµÄÅäÖÃÐÅÏ¢£¨Èç×î³£ÓõÄÉèÖÃASP.NET Web Ó¦ÓóÌÐòµÄÉí·ÝÑéÖ¤·½Ê½£©£¬Ëü¿ÉÒÔ³öÏÖÔÚÓ¦ÓóÌÐòµÄÿһ¸öĿ¼ÖС£µ±Äãͨ¹ýVB.NETн¨Ò»¸öWebÓ¦ÓóÌÐòºó£¬Ä¬ÈÏÇé¿ ......

ASP.NET ²Ù×÷MySQLÊý¾Ý¿âµÄ·½·¨ËµÃ÷

using System;
using System.Data;
using System.Diagnostics;
using System.Collections.Generic;
using MySql.Data.MySqlClient;
namespace System
{
 /// <summary>
 /// Description of MySqlDBUtil.
 /// </summary>
 public class MySqlDBUtil
 {
  &nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ