asp.net从sql server2005中查询数据
首先要添加
using System.Data;
using System.Data.SqlClient;
接下来:
SqlConnection conn = new SqlConnection("server=QLPC\\SQL2005;uid=sa;pwd=(你的密码);database=(你的数据表)"); //用于连接数据库
conn.Open(); //打开数据库
SqlCommand cmd = new SqlCommand("select * from [user]", conn); //相当于执行数据语句吧
SqlDataReader read = cmd.ExecuteReader(); //创建一个SqlDataReader的read象
while (read.Read()) //当读取的数据存在时则写出来
{
Response.Write(read[0]);
}
conn.close(); //关闭数据库的链接
相关文档:
以前一直觉得linq to sql生成类似where id not in (1,3,5)或where id not in (select id from ...)这样的条件不是很方便,每次我都是把条件ID事先取到一个数组里,然后用 !Arr.Contains(c.Id)这样处理,今天突然发现这样好傻,其实可以完全直接用linq写成一句,贴个示例在这里,以后备查
from a in TableA where !(fr ......
1.首先需要建立plan table,否则不能使用
建立方法:
$oracle\rdbms\admin下有个
utlxplan.sql
其内容为:
create table PLAN_TABLE (
statement_id varchar2(30),
timestamp date,
remarks varchar2(80),
operat ......
随 着网站访问量的加大,每次从数据库读取都是以效率作为代价的,很多用ACCESS作数据库的更会深有体会,静态页加在搜索时,也会被优先考虑。互联网上流 行的做法是将数据源代码写入数据库再从数据库读取生成静态面,这样无形间就加大了数据库。将现有的ASP页直接生成静态页,将会节省很多。
下面的例子是将、index.asp?i ......
<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace ="System.Text" %>
<%@ Import Namespace="System.Data" %>
<%
for (int i = 0; i <= 10; i++)
......