转自http://www.sharepointnerd.com/blog/Lists/Posts/Post.aspx?ID=24

已经过我的验证,切实好用。

用户Attach Database的代码:http://msdn.microsoft.com/en-us/library/ms190209.aspx

  1. In Central Administration, take the content database offline.
  2. In Central Administration, remove the content database from SharePoint.  You'll get a warning here that any sites in that content database will no longer be available in SharePoint.  While that is true, it does not mean that you're deleting sites; the sites and all their data will remain in the content database.
  3. In SQL Server, detach the database.  During this process, it may be necessary for you to also drop all existing connections to the database.
  4. In SQL Server, re-attach the same database.  During this process, you should see an "Attach as" column in the upper table; it's here that you can change the name of the database, so call it what you want.  Perform the re-attachment.
  5. In Central Administration, add a content database.
    1. Be sure you have the correct web application selected.
    2. Give the "new" database the same name as the one you specified in SQL Server in step 4 above.  (You're not really "creating" a database at  this point because you want to use the existing one that you just re-attached).
    3. Click the "OK" button.
  6. The database should now appear as an available database in Central Administration.  If it's not "Started," be sure to start it.  You should then be able to navigate to any site collection contained in the content database.




posted @ 2012-04-01 22:33 队长 阅读(2) 评论(0) 编辑
asp.net在win2003中会以network service身份运行,可能需要为该帐户设置权限
 
FreeDiskSpaceViewer.aspx
--Code Begin----------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" %>
 
<html>
<head runat="server">
    <title></title>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
            ArrayList localDrives = new ArrayList();
            foreach (System.IO.DriveInfo drive in drives)
            {
                if (drive.DriveType == System.IO.DriveType.Fixed)
                {
                    MyDriveInfo di = new MyDriveInfo();
                    di.Name = drive.Name;
                    di.AvailableFreeSpace = drive.AvailableFreeSpace / 1024m / 1024m / 1024m;
                    di.TotalSize = drive.TotalSize / 1024m / 1024m / 1024m;
                    localDrives.Add(di);
                }
            }
            GridView1.DataSource = localDrives;
            GridView1.DataBind();
        }
 
        public class MyDriveInfo
        {
            private string _name;
            public string Name
            {
                get
                {
                    return _name;
                }
                set
                {
                    _name = value;
                }
            }
 
            private decimal _availableFreeSpace;
            public decimal AvailableFreeSpace
            {
                get
                {
                    return _availableFreeSpace;
                }
                set
                {
                    _availableFreeSpace = value;
                }
            }
 
            private decimal _totalSize;
            public decimal TotalSize
            {
                get
                {
                    return _totalSize;
                }
                set
                {
                    _totalSize = value;
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <span>Drive Information</span>
        <asp:GridView ID="GridView1"
            runat="server" AutoGenerateColumns="false">
            <%-- Name DriveFormat IsReady AvailableFreeSpace TotalFreeSpace TotalSize VolumeLabel --%>
           <Columns>
            <asp:BoundField DataField="Name" HeaderText="Name" />
            <asp:BoundField DataField="AvailableFreeSpace" HeaderText="AvailableFreeSpace" DataFormatString="{0:n2} g" />
            <asp:BoundField DataField="TotalSize" HeaderText="TotalSize" DataFormatString="{0:n2} g" />
            </Columns>
        </asp:GridView>
    </div>
    </form>
</body>
</html>
--Code End----------------------------------------------------




posted @ 2012-03-22 09:45 队长 阅读(4) 评论(0) 编辑

在js中有三个url编码函数:escape,encodeURI, encodeURIComponent。

escape引人的最早,它会将unicode字符编码成%uXXXX,而其它两个函数会先得到utf8结果然后%xx%yy%zz
我们应该使用encodeURI和encodeURIComponent而不是escape,新的总是好的嘛:)

encodeURI和encodeURIComponent的区别是前者不会对:/?&=等字符进行编码,主要用于对url主体进行编码(协议端口+路径+页面,不适合对带查询字符串的整个url进行编码)
而encodeURIComponent用于对url组件进行编码,例如对查询字符串进行编码。

asp.net中的服务器端方法HttpUtility.UrlEncode的作用相当于encodeURIComponent,但是它会把空格转换成+而不是%20
HttpUtility.UrlEncode("http://www.google.com/test page.aspx?title=hello world")
http%3a%2f%2fwww.google.com%2ftest+page.aspx%3ftitle%3dhello+world
由此看来它只适用于对查询字符串的值进行编码

如果调用HttpUtility.UrlPathEncode,他只转换前面部分
HttpUtility.UrlPathEncode("http://www.google.com/test page.aspx?title=hello world&name=once more")
http://www.google.com/test%20page.aspx?title=hello world&name=once more

 

再看一个例子:encodeURI("http://www.google.com/test page.aspx?title=hello world")
http://www.google.com/test%20page.aspx?title=hello%20world
escape, encodeURI, encodeURIComponent这三个js函数一律将空格处理成%20,而服务器端的方法会将空格处理成+号,悲剧的是没有内置的js函数可以正确转换hello+world这样的查询字符串值


参考:http://kb.cnblogs.com/page/133765/





posted @ 2012-03-06 09:53 队长 阅读(8) 评论(0) 编辑
方法一, 检查文件系统
%systemroot%\Microsoft.NET\Framework
方法二,检查注册表 (http://stackoverflow.com/questions/199080/how-to-detect-what-net-framework-versions-and-service-packs-are-installed)
1.0                HKLM\Software\Microsoft\.NETFramework\Policy\v1.0\3705 1.1                HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322\Install 2.0                HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\Install 3.0                HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup\InstallSuccess 3.5                HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\Install 4.0 Client Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Client\Install4.0 Full Profile   HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full\Install




posted @ 2012-03-01 14:46 队长 阅读(13) 评论(0) 编辑
在我的上一篇Blog中,我介绍了如何 实现一个SiteCollection一个ContentDatabase
 
在今天的实践中,我们遇到了一个新问题
 
当调用Create-SC-OwnCDB (自定义函数,参见上一篇Blog)创建SiteCollection时,一个空的SiteCollection被成功创建,并且数据存放在指定的ContentDatabase中,一切按照计划进行。
但是当我调用Restore-SPSite企图用之前的SiteCollection备份覆盖新创建的空SiteCollection时,结果发生了意外:这个备份被恢复到了其他ContentDatabase中。查了一下Restore-SPSite命令的帮助,发现有一个-ContentDatabase参数,参数说明如下:
Specifies the SQL Server content database where the site collection data will be stored. If no content database is specified, the content database with the greatest unused site collection capacity and whose database status is ready will be used.
 
个人认为这种默认设置不合理,我觉得默认应该使用被覆盖的SiteCollection所在的ContentDatabase,而不是当前可用的具有最大SiteCollection可用数量(MaxSiteCount - CurrentSiteCount)的那个ContentDatabase。
 
最后的解决办法是用Move-SPSite将那个SiteCollection移动到我们期望的ContentDatabase中:
Move-SPSite -Identity http://mysharepointsite.com.au/sites/user -destinationdatabase WSS-Content-NewUserDB
 
这个命令提示需要重启IIS,于是在每台FEW服务器中执行IISRESET命令。
 
有谁知道简单的方式实现自动重启所有的FEW中的IIS? 望不吝赐教!





posted @ 2012-02-28 22:14 队长 阅读(70) 评论(0) 编辑
摘要: 在Sharepoint中,一个WebApplication可以有一个到多个ContentDatabase,而一个SiteCollection只能在一个ContentDatabase中(不能跨ContentDB)。如果Farm Administrator不手动添加,可能就会一直用一个ContentDB,其结果就是多个SiteCollection共享一个ContentDB,这本身没有大的问题,因为一个ContentDB即使大到100G,据说Sharepoint也可以管理得很好。但是作为Best Practice,推荐是为每一个SiteCollection使用独立的ContentDB,这样便于管理,阅读全文
posted @ 2012-02-27 22:25 队长 阅读(96) 评论(0) 编辑
摘要: 今天在调试一个asp程序的时候,当调用conn.Open方法时得到如下错误:[Microsoft][ODBC SQL Server Driver][DBNETLIB] Invalid connection.连接字符串一点问题都没有,可就是提示连接失败driver={SQL Server};server=ServerPCName;uid=usera;pwd=123456;database=FBIgo...阅读全文
posted @ 2012-02-21 16:49 队长 阅读(11) 评论(0) 编辑
摘要: 参考: http://msdn.microsoft.com/zh-cn/library/ee539975.aspxSPList list = web.Lists["Orders"]; SPQuery query = new SPQuery();query.Joins = @" <Join Type=’LEFT’ ListAlias=’customers’> <Eq> <FieldRef Name=...阅读全文
posted @ 2012-02-05 22:24 队长 阅读(16) 评论(0) 编辑
摘要: <?xml version="1.0" encoding="utf-8" ?><Feature Id="21003D96-D88E-42ed-AF97-2C4C22BFA3CF" Title="Test Web Application Feature" Description="I should be activated by default." Version="1.0.0.0" ...阅读全文
posted @ 2012-01-13 10:05 队长 阅读(18) 评论(0) 编辑
摘要: 1. 如何表达枚举类型?[StringSplitOptions] $option = "None"[StringSplitOptions] $option = "RemoveEmptyEntries"2. 在bat中调用执行Powershell文件(相对路径)powershell.exe -Command "& {.\Script1.ps1}"3.加入-NoExit参数执行ps1文件PowerSh...阅读全文
posted @ 2012-01-11 09:07 队长 阅读(34) 评论(0) 编辑