解决 tempdb 中磁盘空间不足的问题、tempdb变得比较大,已经把磁盘占满的问题解决:
1、最简单的办法:重启SQL Server服务(这个是简单的方法,重启后,tempdb数据库会还原到初始状态,也就是自动清除临时数据)
2、如果SQL Server 是安装在默认路径,那么 tempdb.mdf 和 templog.ldf 文件在以下路径:
“C:\Program Files\Microsoft SQL Server\MSSQL\Data\”
解决 tempdb 中磁盘空间不足的问题、tempdb变得比较大,已经把磁盘占满的问题解决:
1、最简单的办法:重启SQL Server服务(这个是简单的方法,重启后,tempdb数据库会还原到初始状态,也就是自动清除临时数据)
2、如果SQL Server 是安装在默认路径,那么 tempdb.mdf 和 templog.ldf 文件在以下路径:
“C:\Program Files\Microsoft SQL Server\MSSQL\Data\”
对于SQL Server 2008,有几个地方是要注意的,比方在还原数据库时,这就使还原的数据库文件制定为. bak。还原数据库时,如果出现“备份集中的数据库备份与现有数据库不同”错误的,使用下面的方法进行还原。
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();
}
}
} 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();
}
}
}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;
}
}
二维码又称QR Code,QR全称Quick Response,是一个近几年来移动设备上超流行的一种编码方式,它比传统的Bar Code条形码能存更多的信息,也能表示更多的数据类型:比如:字符,数字,日文,中文等等。这两天学习了一下二维码图片生成的相关细节,觉得这个玩意就是一个密码算法,在此写一这篇文章 ,揭露一下。供好学的人一同学习之。
Android开发学习:开发过程中会需要对App应用进行判断是否是首次启动,或安装后第一次打开应用。
package com.zhengdecai.isfirststart;
import android.app.Activity;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;
import android.widget.Toast;
/**
* 首次启动判断
*
* @author 郑德才
*
*/
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView isFisrt =(TextView) findViewById(R.id.isFisrt);
SharedPreferences sharedPreferences = this.getSharedPreferences(
"share", MODE_PRIVATE);//此处表示该应用程序专用
boolean isFirstRun = sharedPreferences.getBoolean("isFirstRun", true);//此处表示如果key "isFirstRun"对应的value没有值则默认为true,否则就把对应的value取出赋值给变量isFirstRun
Editor editor = sharedPreferences.edit();
editor.putBoolean("isFirstRun", false); //此处表示putBoolean(key, value),将value写入对应的key,而且是一一对应的
editor.commit(); //将isFirstRun写入editor中保存
if (isFirstRun) {
Log.d("debug", "第一次运行");
editor.putBoolean("isFirstRun", false);
Toast.makeText(this, "是第一次运行程序喔!", Toast.LENGTH_SHORT).show();
isFisrt.setText("是第一次运行程序喔!");
editor.commit();
} else {
Log.d("debug", "不是第一次运行");
Toast.makeText(this, "已经不是第一次运行程序了!", Toast.LENGTH_SHORT).show();
isFisrt.setText("已经不是第一次运行程序了!");
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}Android开发学习
Android开发中,通过应用程序发送短信验证码,并监听短信内容把短信验证码自动填充到文本框中,通过BroadcastReceiver检测接收的短信内容(6位数字的验证码)
Android开发学习
Android开发中,对应用程序创建手机桌面快捷方式
Android开发学习
Android开发中,需要用到模仿QQ联系人的菜单展开收缩效果
package com.zhengdecai.awaveinfo;
import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
以前听说过PowerDesigner可以和数据库连接,根据在PowerDesigner创建的数据模型创建表、触发器、存储过程到数据库中。也可以将已有的数据库导出到PowerDesigner中为数据模型。今天做了一下测试,发现确实很简单,现在操作步骤与大家分享:
0、准备工作
先在SQL Server中创建一数据库,以供测试用。
Create database test
1、 根据在PowerDesigner创建的数据模型创建表、触发器、存储过程到数据库中
1)打开PowerDesigner ,建立一个物理数据模型
在做Mobile终端的Website开发中,我遇到一个很懊恼的问题。
在IOS中的Safari浏览器有的不能正确解释出Javascript中的 new Date('2013-10-21') 的日期对象。
但是在IOS版本里面的Safari解释new Date('2013-10-21') 就不正确,在IOS的Safari中返回的永远会是"Invalid Date"。
后来我在网上查找了资料,原来是低版本的Safari解释new Date('2013-10-21')这个对象不一样,在IOS中的Safari不支持这种写法,
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
Android开发学习
Android开发中,自动显示搜索历史成列表
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>