{
SqlConnection cnn = new SqlConnection
("context connection=true");
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "select * from customers";
SqlDataReader reader = cmd.ExecuteReader();
SqlContext.Pipe.Send(reader);
reader.Close();
cnn.Close();
}
这个GetAllCustomers()方法用了一个[SqlProcedure]属性来修饰。 在方法内创建一个SqlConnection和一个SqlCommand对象。 然后使用ExecuteReader()方法来执行SELECT语句。 接下来用Send()方法将取得的SqlDataReader数据发送到客户端。 最后就是关闭SqlDataReader和SqlConnection。 在这种方法中,是我们自己创建的SqlDataReader。 其实,我们也能够把这个任务交给SqlContext类去完成,代码如下:
[SqlProcedure]
public static void GetCustomerByID
(SqlString CustomerID)
{
SqlConnection cnn = new SqlConnection
("context connection=true");
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "select * from customers
where customerid=@p1";
SqlParameter p1 = new SqlParameter("@p1", Cu ......
{
SqlConnection cnn = new SqlConnection
("context connection=true");
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "select * from customers";
SqlDataReader reader = cmd.ExecuteReader();
SqlContext.Pipe.Send(reader);
reader.Close();
cnn.Close();
}
这个GetAllCustomers()方法用了一个[SqlProcedure]属性来修饰。 在方法内创建一个SqlConnection和一个SqlCommand对象。 然后使用ExecuteReader()方法来执行SELECT语句。 接下来用Send()方法将取得的SqlDataReader数据发送到客户端。 最后就是关闭SqlDataReader和SqlConnection。 在这种方法中,是我们自己创建的SqlDataReader。 其实,我们也能够把这个任务交给SqlContext类去完成,代码如下:
[SqlProcedure]
public static void GetCustomerByID
(SqlString CustomerID)
{
SqlConnection cnn = new SqlConnection
("context connection=true");
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "select * from customers
where customerid=@p1";
SqlParameter p1 = new SqlParameter("@p1", Cu ......
{
SqlConnection cnn = new SqlConnection
("context connection=true");
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "select * from customers";
SqlDataReader reader = cmd.ExecuteReader();
SqlContext.Pipe.Send(reader);
reader.Close();
cnn.Close();
}
这个GetAllCustomers()方法用了一个[SqlProcedure]属性来修饰。 在方法内创建一个SqlConnection和一个SqlCommand对象。 然后使用ExecuteReader()方法来执行SELECT语句。 接下来用Send()方法将取得的SqlDataReader数据发送到客户端。 最后就是关闭SqlDataReader和SqlConnection。 在这种方法中,是我们自己创建的SqlDataReader。 其实,我们也能够把这个任务交给SqlContext类去完成,代码如下:
[SqlProcedure]
public static void GetCustomerByID
(SqlString CustomerID)
{
SqlConnection cnn = new SqlConnection
("context connection=true");
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "select * from customers
where customerid=@p1";
SqlParameter p1 = new SqlParameter("@p1", Cu ......
很多技术爱好者的电脑上总是安装了很多软件,包括应用软件、开发工具软件及数据库软件,但是随着时间的流逝,慢慢地电脑上装的软件已经超出了电脑本身所能
承载的量了,因而出现了电脑运行速度慢等问题。同时,也有一些单位或个人的电脑由于出厂年代有些久远,即使只安装一种或极少数软件时也会显示出运行速度慢
的现象。如果我们并不是太频繁使用某些软件,为了加快机器的运行响应速度,我们就会选择暂停这些软件相关的服务以减轻内存、CPU的负载。下面我们将
SQL Server 2005作为一个例子来介绍一下。
SQL
Server本身是一个很占资源的软件,光一个实例服务所占内存,根据其安装时分配的内存就至少要达到256MB以上,再加上其他附属服务,光内存就要占
用物理内存的20-30%左右,至于CPU,SQL Server也需要占用20%左右,因而,我们考虑在有需要使用SQL
Server时启用其相关服务,平时则停止该服务。
我们拿SQL Server
2005作为例子。首先在“开始=〉运行”中输入“services.msc”,按回车,进入“服务”控制台,将SQL Server (MSSQLSE ......
外联接:外联接可以是左向外联接、右向外联接或完整外部联接。
在 from 子句中指定外联接时,可以由下列几组关键字中的一组指定:
LEFT JOIN 或 LEFT OUTER JOIN;
左向外联接的结果集包括 LEFT OUTER 子句中指定的左表的所有行,而不仅仅是联接列所匹配的行。如果左表的某行在右表中没有匹配行,则在相关联的结果集行中右表的所有选择列表列均为空值。
......
只需要在配置文件里 hibernate.show_sql=true
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
hibernate.show_sql=true
</value>
</property> ......
例子: int id = Convert.ToInt32(replace((Request.QueryString["id"]), ""));
public static string replace(string str, string str2)
{
str = str.Replace(";", str2);
str = str.Replace("&", str2);
str = str.Replace("<", str2);
str = str.Replace(">", str2);
str = str.Replace("'", str2);
str = str.Replace("--", str2);
str = str.Replace("/", str2);
str = str.Replace("%", str2);
str = str.Replace("~", str2);
str = str.Replace(",", str2);
str = str.Replace("`", str2) ......
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void BulletedList3_Click(object sender, BulletedListEventArgs e)
{//获取被选项的文本值
Response.Write(BulletedList3.Items[e.Index].Text);
}
protected void BulletedList2_DataBound(object sender, EventArgs e)
{//做连接
string[] val = new string[BulletedList2.Items.Count];
for (int i = 0; i < BulletedList2.Items.Count; i++)
&n ......