10 Oct 2005

哭使用Data Access 2 插入Ntext类型数据时SqlParameter不指定类型的问题 , ,请为我解惑

实在郁闷 ,请大家为我解惑。
同发csdn:http://community.csdn.net/Expert/topic/4315/4315539.xml?temp=.3931848

原来的代码

 SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure,
  FullyQualifiedSprocName("P_InsertNtextData"),
  new SqlParameter("@Id", f.Id),
  new SqlParameter("@NtextData",f.Data));

如果 f.Data过长,就莫名其妙的异常,

---------------------------


---------------------------
当前命令发生了严重错误。应放弃任何可能产生的结果。
---------------------------
确定  
---------------------------


---------------------------


---------------------------
常规网络错误。请检查您的网络文档。
---------------------------
确定  
---------------------------

Google baidu 都翻了个底朝天,也没个能安慰我的信息。
试验了一下午,最后试出来写个测试字符串"aaaa"就能插入
尝试了如下代码

 SqlParameter ntext = new SqlParameter("@NtextData",SqlDbType.NText);
 ntext.Value = f.Data;
 SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure,
  FullyQualifiedSprocName("P_InsertNtextData"),
  new SqlParameter("@Id", f.Id),
  ntext);

成功,怎么也想不通这换汤不换药的方法为何能够成功,
翻msdn,
打自己一巴掌

获取或设置参数的 SqlDbType。


[Visual Basic]
Public Property SqlDbType As SqlDbType


[C#]
public SqlDbType SqlDbType {get; set;}



属性值
SqlDbType 值之一。默认值为 NVarChar

然而我又看到另外一个构造器的重载这样说明

[Visual Basic]
Public Sub New( _
   ByVal parameterName As String, _
   ByVal value As Object _
)


[C#]
public SqlParameter(
   string parameterName,
   object value
);



参数
parameterName
要映射的参数的名称。
value
一个 Object,它是 SqlParameter 的值。
备注
当在 value 参数中指定 Object 时,SqlDbType 将从 Object 的 .NET Framework 类型推断出。

这又如何解释??

07 Oct 2005

Communtiy Server论坛的帖子显示页面分页部分的Url Rewrite的构造方法

你可能会发现在Communtiy Server的论坛帖子列表页面

比如http://communityserver.org/forums/129/ShowForum.aspx

看下面分页处的连接使用的地址是类似ShowForum.aspx?PageIndex=2这样的地址
没有做到SearchFriendly,我们稍微改造一下代码就可以实现类似帖子显示页面内那样的地址
先在siteUrl.config内增加

 

<url name="forum_Paged" location = "forums" path = "{0}/{1}/ShowForum.aspx" pattern = "(\d+)/(\d+)/ShowForum.aspx" vanity="ShowForum.aspx?PageIndex=$1^ForumID=$2" />

然后siteUrl.cs内增加
 

public virtual string FormPagedFormat (int forumID)
{
 return urlData.FormatUrl("forum_Paged", "{0}", forumID.ToString(), forumID.ToString());
}

接着ThreadView.cs内paer数据绑定处增加

pager.UrlPattern = SiteUrls.Instance().FormPagedFormat(csContext.ForumID);
 

重新编译,OK,看看效果吧~~

http://www.3pub.com/bbs/3/default.aspx

07 Oct 2005

Communtiy Server论坛的帖子显示页面分页部分的Url Rewrite的构造方法

你可能会发现在Communtiy Server的论坛帖子列表页面

比如http://communityserver.org/forums/129/ShowForum.aspx

看下面分页处的连接使用的地址是类似ShowForum.aspx?PageIndex=2这样的地址
没有做到SearchFriendly,我们稍微改造一下代码就可以实现类似帖子显示页面内那样的地址
先在siteUrl.config内增加

 

<url name="forum_Paged" location = "forums" path = "{0}/{1}/ShowForum.aspx" pattern = "(\d+)/(\d+)/ShowForum.aspx" vanity="ShowForum.aspx?PageIndex=$1^ForumID=$2" />

然后siteUrl.cs内增加
 

public virtual string FormPagedFormat (int forumID)
{
 return urlData.FormatUrl("forum_Paged", "{0}", forumID.ToString(), forumID.ToString());
}

接着ThreadView.cs内paer数据绑定处增加

pager.UrlPattern = SiteUrls.Instance().FormPagedFormat(csContext.ForumID);
 

重新编译,OK,看看效果吧~~

http://www.3pub.com/bbs/3/default.aspx

04 Oct 2005

C Community Server 群发Email MassEmailingAdmin.aspx页面内插入表情和代码时,404错误

Email群发的时候:MassEmailingAdmin.aspx页面内插入表情和代码时,404错误

发现是Js文件内路径的问题
FTB-FreeTextBox.js内


 this.iPopup.document.location.href = "../emoticons.aspx";


改成


 this.iPopup.document.location.href = "/emoticons.aspx";


FTB-Pro.js内


 var codeWin = window.open("../insertcode.aspx","codeWin","width=530,height=420,status=0,toolbars=0");


改成


 var codeWin = window.open("/insertcode.aspx","codeWin","width=530,height=420,status=0,toolbars=0");

04 Oct 2005

C Community Server 群发Email MassEmailingAdmin.aspx页面内插入表情和代码时,404错误

Email群发的时候:MassEmailingAdmin.aspx页面内插入表情和代码时,404错误

发现是Js文件内路径的问题
FTB-FreeTextBox.js内


 this.iPopup.document.location.href = "../emoticons.aspx";


改成


 this.iPopup.document.location.href = "/emoticons.aspx";


FTB-Pro.js内


 var codeWin = window.open("../insertcode.aspx","codeWin","width=530,height=420,status=0,toolbars=0");


改成


 var codeWin = window.open("/insertcode.aspx","codeWin","width=530,height=420,status=0,toolbars=0");

04 Oct 2005

使ExpanderPanel的文本带上连接

ExpanderPanel.cs 增加TextHref属性
修改了Text属性的Get方法


if(ResourceName != null)
{  if(TextHref == null)
 {
  return CommunityServer.Components.ResourceManager.GetString(ResourceName);
 }
 else
 {
  return String.Format(”<a href=\“{0}\”>{1}</a>”,this.TextHref,CommunityServer.Components.ResourceManager.GetString(ResourceName));
 }
}

02 Oct 2005

Community Server的新功能--快速回复

进入
http://communityserver.org/forums/498047/ShowPost.aspx

双击鼠标,看效果

但是Firefox/1.0下无效...

02 Oct 2005

Community Server的新功能--快速回复

进入
http://communityserver.org/forums/498047/ShowPost.aspx

双击鼠标,看效果

但是Firefox/1.0下无效...

24 Sep 2005

使用Url Rewrite 如果原始Url就带QueryString时候的一个问题

我重写了我的站点程序,在使用msdn内
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/urlrewriting.asp
关于Url Rewrite的方法


今天发现发现搜索引擎内对于原访问地址的记录还都在,而且有很多朋友通过这些地址访问
我当然不愿意然这些连接全部导向出错页面了,就想在Url Rewirte 内加个规则
<LookFor>为~/ShowArticle.Aspx\?ID=(\d+)
<SendTo>为~/Show.Aspx\?ID=(\d+)
当我这么加了后,访问该页面发现报错误404
仔细看Url Write的代码
最后发现



protected virtual void RewriterModule_AuthorizeRequest(object sender, EventArgs e)
{
 HttpApplication app = (HttpApplication)sender;
 Rewrite(app.Request.Path, app);//看这里,采用的是Request.Path 
}


经过我测试
对一个地址http://localhost/test/requestpath.aspx/sss.aspx?id=2222访问
得到的结果是


request.path:       /test/requestpath.aspx/sss.aspx
Request.Url.ToString():     http://localhost/test/requestpath.aspx/sss.aspx?id=2222
Request.PathInfo:    /sss.aspx
Request.RawUrl:     /test/requestpath.aspx/sss.aspx?id=2222

我将上面的代码改成

protected virtual void RewriterModule_AuthorizeRequest(object sender, EventArgs e)
{
 HttpApplication app = (HttpApplication)sender;
 Rewrite(app.Request.RawUrl, app); 
}


执行我的程序,发现我的程序报错,提示的是我的参数不正确,
跟踪了一下发现QueryString传递了两个ID参数
经过跟踪代码,发现 internal static void RewriteUrl(HttpContext context, string sendToUrl, out string sendToUrlLessQString, out string filePath)内


if (context.Request.QueryString.Count > 0)
{
 if (sendToUrl.IndexOf('?') != -1) 
 {
  sendToUrl += "&" + context.Request.QueryString.ToString();
 }
 else
 {
  sendToUrl += "?" + context.Request.QueryString.ToString();
 }
}
这里将context.Request.QueryString又给sendToUrl加了一边

如果去掉这部分那么虚拟的没有QueryString参数的页面将全部无法传递正确
最后只有在些Rewrite.config的时候


<!--
 如果LookFor内包含QueryString那么在SendTo内就不必写QueryString,
 因为上下文的content的context.Request.QueryString已经传递过去了
-->
<RewriterRule>
 <LookFor>~/ShowArticle.Aspx\?ID=(\d+)</LookFor>
 <SendTo><![CDATA[~/Show.aspx]]></SendTo><!--这里-->
</RewriterRule>

 一切ok了,这样的地址都能访问了
http://www.github.com/ShowArticle.Aspx?ID=214
 :-)
 

24 Sep 2005

使用Url Rewrite 如果原始Url就带QueryString时候的一个问题

我重写了我的站点程序,在使用msdn内
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/urlrewriting.asp
关于Url Rewrite的方法


今天发现发现搜索引擎内对于原访问地址的记录还都在,而且有很多朋友通过这些地址访问
我当然不愿意然这些连接全部导向出错页面了,就想在Url Rewirte 内加个规则
<LookFor>为~/ShowArticle.Aspx\?ID=(\d+)
<SendTo>为~/Show.Aspx\?ID=(\d+)
当我这么加了后,访问该页面发现报错误404
仔细看Url Write的代码
最后发现



protected virtual void RewriterModule_AuthorizeRequest(object sender, EventArgs e)
{
 HttpApplication app = (HttpApplication)sender;
 Rewrite(app.Request.Path, app);//看这里,采用的是Request.Path 
}


经过我测试
对一个地址http://localhost/test/requestpath.aspx/sss.aspx?id=2222访问
得到的结果是


request.path:       /test/requestpath.aspx/sss.aspx
Request.Url.ToString():     http://localhost/test/requestpath.aspx/sss.aspx?id=2222
Request.PathInfo:    /sss.aspx
Request.RawUrl:     /test/requestpath.aspx/sss.aspx?id=2222

我将上面的代码改成

protected virtual void RewriterModule_AuthorizeRequest(object sender, EventArgs e)
{
 HttpApplication app = (HttpApplication)sender;
 Rewrite(app.Request.RawUrl, app); 
}


执行我的程序,发现我的程序报错,提示的是我的参数不正确,
跟踪了一下发现QueryString传递了两个ID参数
经过跟踪代码,发现 internal static void RewriteUrl(HttpContext context, string sendToUrl, out string sendToUrlLessQString, out string filePath)内


if (context.Request.QueryString.Count > 0)
{
 if (sendToUrl.IndexOf('?') != -1) 
 {
  sendToUrl += "&" + context.Request.QueryString.ToString();
 }
 else
 {
  sendToUrl += "?" + context.Request.QueryString.ToString();
 }
}
这里将context.Request.QueryString又给sendToUrl加了一边

如果去掉这部分那么虚拟的没有QueryString参数的页面将全部无法传递正确
最后只有在些Rewrite.config的时候


<!--
 如果LookFor内包含QueryString那么在SendTo内就不必写QueryString,
 因为上下文的content的context.Request.QueryString已经传递过去了
-->
<RewriterRule>
 <LookFor>~/ShowArticle.Aspx\?ID=(\d+)</LookFor>
 <SendTo><![CDATA[~/Show.aspx]]></SendTo><!--这里-->
</RewriterRule>

 一切ok了,这样的地址都能访问了
http://www.github.com/ShowArticle.Aspx?ID=214
 :-)