我在WIN7 64位下使用ACCESS作为网站数据库运行程序的时候,网页报错如下:
14
2016
03
The 'Microsoft.Jet.OleDb.4.0' provider is not registered on the local machine
13
2016
01
jQuery延迟加载插件(懒加载) - jquery.lazyload.js
淡入效果
不在可视范围内的图片不会加载。滚动时按需加载。图片出现时使用的是jquery的淡入效果。请清空缓存重新测试一下。
可以如下demo页面作比较:没有淡入效果的。
24
2015
04
Asp.Net 用微信二维码登录自己的网站
一、当用户选择用微信二维码登录时,我们要在用户页面里生成一个guid做为客户端的唯一标识,然后带着这个guid请求二维码图片地址,得到地址后,显示给用户。请求到后台的时候要将此二维码的Key和客户端的guid关联到一起。注意这个key的生成方式,要保证多人同时用二维码登录而不冲突,比如用10000自增,隔断时间又重置到10000。
15
2015
04
Web App开发入门收藏
自Iphone和Android这两个牛逼的手机操作系统发布以来,在互联网界从此就多了一个新的名词-Web App(意为基于WEB形式的应用程序)。业界关于Web App与Native App的争论已有一段时间,而Hybrid混合App则受到推荐,随着时间的推移,我们相信Web App也会有一定的市场,那么它到底有什么奥秘呢?让我们来看看。
21
2015
03
明升:火箭这个赛季对位开拓者需要注意这几点
最近几场火箭打开拓者都比较难打,特别是对位利拉德和巴托姆这2点,火箭都吃亏,更不要说阿尔德里奇了,霍华德回归还好点,就像上赛季火箭打开拓者一样, 火箭如果再遇开拓者估计结局也一样。明升体育分析到,为什么这么说呢?首先我们看看这个赛季火箭打开拓者和打勇士基本都是处在下风。开拓者老到,稳扎稳打。明升体育为你分析下对位情况。
13
2015
03
在C#中使用正则表达式自动匹配并获取所需要的数据
正则表达式能根据设置匹配各种数据(比如:e-mail地址,电话号码,身份中号码等等)。正则表达式功能强大,使用灵活,C#,Java,JavaScript等多种语言都支持正则表达式。在互联网上“抓取数据”更是少不了使用正则表达式。今天我要说的是在C#中使用正则表达式自动匹配并获取所需要的数据。
从下面是某个IP查询网站返回查询结果的一个部分(字符串),现在就是要从这个字符串中获取“查询结果1:”后面的“北京市 网通”。
03
2015
02
20
2015
01
SQL Server 2008“备份集中的数据库备份与现有的数据库不同”解决方法
对于SQL Server 2008,有几个地方是要注意的,比方在还原数据库时,这就使还原的数据库文件制定为. bak。还原数据库时,如果出现“备份集中的数据库备份与现有数据库不同”错误的,使用下面的方法进行还原。
19
2015
01
使用HttpWebrequest对网站进行模拟操作(附登陆百度demo)
首先 看一个GET请求
public string GetHtml(string url, string Referer, Encoding encode, bool SaveCookie)
{
HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest;
req.Method = "GET";
req.CookieContainer = this.CookieContainer;
req.Proxy = null;
if (!string.IsNullOrEmpty(Referer))
req.Referer = Referer;
using (HttpWebResponse hwr = req.GetResponse() as HttpWebResponse)
{
if (SaveCookie)
{
this.CookieCollection = hwr.Cookies;
this.CookieContainer.GetCookies(req.RequestUri);
}
using (StreamReader SR = new StreamReader(hwr.GetResponseStream(), encode))
{
return SR.ReadToEnd();
}
}
}然后 再看POST
public string PostHtml(string url, string Referer, string data, Encoding encode, bool SaveCookie)
{
HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest;
req.CookieContainer = this.CookieContainer;
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
req.UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:30.0) Gecko/20100101 Firefox/30.0";
req.Proxy = null;
req.ProtocolVersion = HttpVersion.Version10;
if (!string.IsNullOrEmpty(Referer))
req.Referer = Referer;
byte[] mybyte = Encoding.Default.GetBytes(data);
req.ContentLength = mybyte.Length;
using (Stream stream = req.GetRequestStream())
{
stream.Write(mybyte, 0, mybyte.Length);
}
using (HttpWebResponse hwr = req.GetResponse() as HttpWebResponse)
{
if (SaveCookie)
{
this.CookieCollection = hwr.Cookies;
this.CookieContainer.GetCookies(req.RequestUri);
}
using (StreamReader SR = new StreamReader(hwr.GetResponseStream(), encode))
{
return SR.ReadToEnd();
}
}
}23
2014
12
11
2014
12
(Asp.Net、C#)FTP常用的操作
using System.IO;
using System.Net;
using System.Text;
using System.Diagnostics;
using System.Text.RegularExpressions;
//从ftp上下载文件
private void Download(string filePath, string ImageSrc, string ImageName, string ftpServerIP, string ftpUserName, string ftpPwd)
{
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
using (FileStream OutputStream = new FileStream(filePath + "\\" + ImageName, FileMode.Create))
{
FtpWebRequest ReqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" +
ImageSrc));
ReqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
ReqFTP.UseBinary = true;
ReqFTP.Credentials = new NetworkCredential(ftpUserName, ftpPwd);
using (FtpWebResponse response = (FtpWebResponse)ReqFTP.GetResponse())
{
using (Stream FtpStream = response.GetResponseStream())
{
long Cl = response.ContentLength;
int bufferSize = 2048;
int readCount;
byte[] buffer = new byte[bufferSize];
readCount = FtpStream.Read(buffer, 0, bufferSize);
while (readCount > 0)
{
OutputStream.Write(buffer, 0, readCount);
readCount = FtpStream.Read(buffer, 0, bufferSize);
}
FtpStream.Close();
}
response.Close();
}
OutputStream.Close();
}
}
//从服务器上传文件到FTP上
private void UploadSmall(string sFileDstPath, string FolderName, string ftpServerIP, string ftpUserName, string ftpPwd)
{
FileInfo fileInf = new FileInfo(sFileDstPath);
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" + FolderName + "/" +
fileInf.Name));
reqFTP.Credentials = new NetworkCredential(ftpUserName, ftpPwd);
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
reqFTP.UseBinary = true;
reqFTP.ContentLength = fileInf.Length;
int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;
using (FileStream fs = fileInf.OpenRead())
{
using (Stream strm = reqFTP.GetRequestStream())
{
contentLen = fs.Read(buff, 0, buffLength);
while (contentLen != 0)
{
strm.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
}
strm.Close();
}
fs.Close();
}
}
//删除服务器上的文件
private void DeleteWebServerFile(string sFilePath)
{
if (File.Exists(sFilePath))
{
File.Delete(sFilePath);
}
}
//删除FTP上的文件
private void DeleteFtpFile(string[] IName, string FolderName, string ftpServerIP, string ftpUserName, string ftpPwd)
{
foreach (string ImageName in IName)
{
string[] FileList = GetFileList(FolderName, ftpServerIP, ftpUserName, ftpPwd);
for (int i = 0; i < FileList.Length; i++)
{
string Name = FileList[i].ToString();
if (Name == ImageName)
{
FtpWebRequest ReqFTP;
ReqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" +
FolderName + "/" + ImageName));
ReqFTP.Credentials = new NetworkCredential(ftpUserName, ftpPwd);
ReqFTP.KeepAlive = false;
ReqFTP.Method = WebRequestMethods.Ftp.DeleteFile;
ReqFTP.UseBinary = true;
using (FtpWebResponse Response = (FtpWebResponse)ReqFTP.GetResponse())
{
long size = Response.ContentLength;
using (Stream datastream = Response.GetResponseStream())
{
using (StreamReader sr = new StreamReader(datastream))
{
sr.ReadToEnd();
sr.Close();
}
datastream.Close();
}
Response.Close();
}
}
}
}
}
//检查文件是否存在
public string[] GetFileList(string FolderName, string ftpServerIP, string ftpUserName, string ftpPwd)
{
string[] downloadFiles;
StringBuilder result = new StringBuilder();
FtpWebRequest reqFTP;
try
{
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" + FolderName +
"/"));
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(ftpUserName, ftpPwd);
reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
WebResponse response = reqFTP.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string line = reader.ReadLine();
while (line != null)
{
result.Append(line);
result.Append("\n");
line = reader.ReadLine();
}
// to remove the trailing '\n'
result.Remove(result.ToString().LastIndexOf('\n'), 1);
reader.Close();
response.Close();
return result.ToString().Split('\n');
}
catch (Exception ex)
{
downloadFiles = null;
return downloadFiles;
}
}
//从客户端上传文件到FTP上
private void UploadFtp(HttpPostedFile sFilePath, string filename, string FolderName, string ftpServerIP, string ftpUserName, string ftpPwd)
{
//获取的服务器路径
//FileInfo fileInf = new FileInfo(sFilePath);
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" + FolderName + "/" +
filename));
reqFTP.Credentials = new NetworkCredential(ftpUserName, ftpPwd);
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
reqFTP.UseBinary = true;
reqFTP.ContentLength = sFilePath.ContentLength;
//设置缓存
int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;
using (Stream fs = sFilePath.InputStream)
{
using (Stream strm = reqFTP.GetRequestStream())
{
contentLen = fs.Read(buff, 0, buffLength);
while (contentLen != 0)
{
strm.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
}
strm.Close();
}
fs.Close();
}
}
//创建目录
private void CreateDirectory(string FolderName, string ftpServerIP, string ftpUserName, string ftpPwd)
{
//创建日期目录
try
{
FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" +
FolderName));
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(ftpUserName, ftpPwd);
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.MakeDirectory;
FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
}
catch
{
ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统忙,请稍后再
试!');location.href=location.href;</script>");
}
}
//检查日期目录和文件是否存在
private static Regex regexName = new Regex(@"[^\s]*$", RegexOptions.Compiled);
private bool CheckFileOrPath(string FolderName, string ftpServerIP, string ftpUserName, string ftpPwd)
{
//检查一下日期目录是否存在
FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/"));
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(ftpUserName, ftpPwd);
reqFTP.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
Stream stream = reqFTP.GetResponse().GetResponseStream();
using (StreamReader sr = new StreamReader(stream))
{
string line = sr.ReadLine();
while (!string.IsNullOrEmpty(line))
{
GroupCollection gc = regexName.Match(line).Groups;
if (gc.Count != 1)
{
throw new ApplicationException("FTP 返回的字串格式不正确");
}
string path = gc[0].Value;
if (path == FolderName)
{
return true;
}
line = sr.ReadLine();
}
}
return false;
}
}
23
2014
11
二维码的生成细节和原理
二维码又称QR Code,QR全称Quick Response,是一个近几年来移动设备上超流行的一种编码方式,它比传统的Bar Code条形码能存更多的信息,也能表示更多的数据类型:比如:字符,数字,日文,中文等等。这两天学习了一下二维码图片生成的相关细节,觉得这个玩意就是一个密码算法,在此写一这篇文章 ,揭露一下。供好学的人一同学习之。
28
2014
09
26
2014
08
PowerDesigner连接SQL Server
以前听说过PowerDesigner可以和数据库连接,根据在PowerDesigner创建的数据模型创建表、触发器、存储过程到数据库中。也可以将已有的数据库导出到PowerDesigner中为数据模型。今天做了一下测试,发现确实很简单,现在操作步骤与大家分享:
0、准备工作
先在SQL Server中创建一数据库,以供测试用。
Create database test
1、 根据在PowerDesigner创建的数据模型创建表、触发器、存储过程到数据库中
1)打开PowerDesigner ,建立一个物理数据模型
19
2014
08
JavaScript获取网页、屏幕、元素对象高度(详细整理)
JavaScript获取网页高度包括(网页可见区域高,屏幕分辨率的高,屏幕可用工作区高度,JavaScript获取浏览器高度,JavaScript获取屏幕高度)等等,各种高度,本文详细整理了一些,需要了解的朋友可以参考下
网页可见区域宽: document.body.clientWidth
网页可见区域高: document.body.clientHeight
网页可见区域宽: document.body.offsetWidth (包括边线的宽)
网页可见区域高:
document.body.offsetHeight (包括边线的高)
网页正文全文宽: document.body.scrollWidth
网页正文全文高: document.body.scrollHeight
网页被卷去的高: document.body.scrollTop
网页被卷去的左: document.body.scrollLeft
网页正文部分上: window.screenTop
网页正文部分左:
window.screenLeft
屏幕分辨率的高: window.screen.height
屏幕分辨率的宽:
window.screen.width
屏幕可用工作区高度: window.screen.availHeight
屏幕可用工作区宽度:
window.screen.availWidth
05
2014
08
jQuery实现元素的上下移动示例代码
jQuery实现元素的上下移动示例代码
<html>
<head>
<title>
</title>
<style type="text/css">
table { background:#949494; width:400px; line-height:20px;} td { border-right:1px
solid gray; border-bottom:1px solid gray; }
</style>
<script src="jquery.js" type="text/javascript">
</script>
28
2014
06
SQLSERVER2008 18456错误
百度搜18456错误几乎只能搜到一篇文章,并不是说结果条数,而是所有的文章都是转自一处。我也遇到了18456错误。
09
2014
05
Excel操作工具类ExcelHelper
这个类库主要是针对我目前的项目写的,比较乱,没时间整理,这段时间有很多网友问我Asp.net中Excel操作的问题,我这里把我的代码公布给大家,希望对大家有帮助。
这个类库没有提供Excel样式设置的方法,建议使用模板,可以在模板中把格式控制好;ExcelHelper提供了实现Excel的基本操作的一些方法,包括:
1、将二维数组和DataTable的数据导入Excel,可以按指定每页的记录行数来分页,还可以将数据相同的行合并
2、WorkSheet的拷贝、隐藏方法,删除操作会出问题,不过对于WorkSheet这两个方法足够了
3、Excel行、列的拷贝、删除、插入、合并操作
4、Excel单元格的拷贝、删除、插入、合并操作,可以将单个文本值写入单元格,也可以将多个值及其对应Excel单元格的位置信息保存在Hashtable中写入单元格
5、Excel文本框赋值操作,一些Excel控件都没有提供访问文本框的方法,要不我也不用写这个类库了
6、将Excel文件导出多种格式
在开发的过程中发现的几个问题:
1、Exce进程结束问题,我目前使用的方法好像对专业版的OS没用,要用ntsd -c q -p pid命令才能结束掉
2、并发问题,如果有两个人同时操作Excel组件的时候就会出错,不知大家有没有好的解决方法,好像使用进程池可以解决这个问题
3、Excel组件访问权限的配置问题,见我以前写的随笔关于在ASP.NET中以DCOM方式操作Excel的几个问题
这个类库有几个方法还有点问题,大家使用过程中有什么问题和改进意见请跟我联系
点这里下载ExcelHelper.rar
10
2014
01
Js读取/获取地址Url所传参数值
今天碰到要在一个页面获取另外一个页面url传过来的参数,一开始很本能的想到了用 split("?")这样一步步的分解出需要的参数。
后来想了一下,肯定会有更加简单的方法的!所以在网上找到了两个很又简单实用的方法
方法一:正则分析法
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
这样调用:
alert(GetQueryString("参数名1"));
alert(GetQueryString("参数名2"));
alert(GetQueryString("参数名3"));
10
2013
12
C#或Asp.Net实现Ftp各种操作(上传,下载,删除文件,创建目录,删除目录,获得文件列表)
C#或Asp.Net实现Ftp各种操作类:
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;