asp.net连接access数据库进行添加更新删除查询操作
连接access数据库代码,写在一个单独的类里
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
namespace AppWebDLL
{
public class ConnApp
{
public OleDbConnection getCon() {
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+System.Web.HttpContext.Current.Server.MapPath("App_Data\\UserDB.mdb")+";Jet OLEDB:Database Password=admin";
OleDbConnection objConnection = new OleDbConnection(strConnection);
return objConnection;
}
}
}
我这习惯这样写的,在这里System.Web.HttpContext.Current.Server.MapPath是用来取得access的相对路径的,在这个类里想要使用System.Web.HttpContext.Current.Server.MapPath,先要引用system.web这个类。
增删改查代码,以我的类写的,这里要注意一个,如果你的字段和access的关键字一样,那么你就要在你的字段上加 [ ],如password是access的关键字,如果你的字段有这个,你在做操作的时候就要这样写[password]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AppWebDLL;
using System.Data;
using System.Data.OleDb;
using System.Collections;
namespace AppBLL
{
public class Land
{
ConnApp capp = new ConnApp();
OleDbConnection db;
OleDbCommand olecom = null;
//查询所有用户
public ArrayList GetAllUser() {
ArrayList alluserlist = new ArrayList();
db = capp.getCon();
try
{
string sql = "select USERNAME from userinfo";
olecom = new OleDbComman
相关文档:
此处提供的代码用来实现当asp.net页面中的某个Button被点击后disable掉该页面中所有的Button,从而防止提交延时导致的多次提交。基于之前的onceclickbutton脚本.
//ASP.NET中防止页面多次提交的代码:javascript< script language=”javascript”> < !– function disableOtherSubmit() {
var obj ......
public static void GetHtml(string url,string savepath)//url参数为将要生成的那个动态页面的地址,savepath为要存放地址
{
string Result;
WebResponse MyResponse;
WebRequest MyRequest = System.Net.HttpWebRequest.Create(url);
MyResponse = MyReque ......
AJAX是Asynchronous JavaScript and XML缩写。这个概念代表的是一种技术,当您在说“我在项目中使用了AJAX技术时”,只是代表了您使用客户端XMLHttpRequest对象与服务器端进行异步通信。不过因为随着AJAX技术的运用往往会带来丰富的客户端效果,因此对AJAX技术的广义理解也可以认为这是一种操作 ......
引用命名空间
using System.Diagnostics;
string sPath = "d:\\test\\test.bat";
string sDict = "d:\\test\\";
ProcessStartInfo psi = new ProcessStartInfo("cmd.exe ......