asp.net平台上连接数据库
今天纠结了一上午的问题,于下午3点12分尘埃落定!
事情是这样的:
作为一个里程碑记录下吧,也算是我第一次将asp.net与数据库结合,并完成从软件编程到web的过渡。
在此感谢今天为我解决问题的“杀手”(也称老道),还有以前为我解决问题的大队、御风、华哥等牛...
言归正传,本文介绍一下怎样在asp.net平台上连接数据库:(C#编写的软件连接数据库见前几篇)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Runtime.InteropServices;
using System.Configuration;
using System.Web.UI.WebControls;
using System.Web.Services.Description;
public partial class _Default : System.Web.UI.Page
{
static DataSet ds;
int index;
protected void Page_Load(object sender, EventArgs e)
{
//set mode of textbox2 as password
//在asp.net中设置textbox 属性为password (C#中是passwordchar = ……)
TextBox2.TextMode = TextBoxMode.Password ;
//count the num of user,as we can add the new user with index++(as id)
string strConnection = ConfigurationManager.AppSettings["Str.Properties.Settings.masterConnectionString"].ToString();
SqlConnection objConnection = new SqlConnection(strConnection);
objConnection.Open();
string sql = "count user num";
sql="select userid as userid,name as name from judging";
SqlDataAdapter adp = new SqlDataAdapter(sql, objConnection);
ds = new DataSet();
ds.Clear();
adp.Fill(ds, "judging");
index = ds.Tables[0].Rows.Count+1;
}
//Register function
protected void Button1_Click(object sender, EventArgs e)
{
/******************method 1*******************/
//string strConnection = "Data Source=ZRQ-PC;";
//strConnection += "Initial Catalog=master;Integrated Security=True";
//SqlConne
相关文档:
在asp.net中导出excel 中比较通行的做法是: Response.ContentType = "application/vnd.ms-excel";
然后直接向里面扔 html 的table
但是有中文的时候 老出现乱码,有很多解决方案,但都不能通盘解决, 就是在 输出html两头输出
Response.Write("<html><head><meta http-equiv=Content-Type conte ......
在Windows NT中,图形多媒体系统基于层次结构。应用程序与顶层的API(实际上是多个用户模式的系统DLL,比如GDI32.DLL)交互,这些系统DLL最终会通过系统服务调用处于内核模式的系统服务。
NT系统的详细信息可参考《Windows 图形编程》的第一、二章。在Windows Vista中,图形系统已经移出了内核模式,并有自己的空间 ......
//TransmitFile实现下载
protected void Button1_Click(object sender, EventArgs e)
{
/*
微软为Response对象提供了一个新的方法TransmitFile来解决使用Respo ......
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="s ......
ASP.NET 首页性能的十大做法
前言
本文是我对ASP.NET页面载入速度提高的一些做法,这些做法分为以下部分:
1.采用 HTTP Module 控制页面的生命周期。
2.自定义Response.Filter得到输出流stream生成动态页面的静态内容(磁盘缓存)。
3.页面GZIP压缩。
4.OutputCache 编程方式输出页面缓存。
5.删除页面空白字符串 ......