分类目录归档:VB & VB.NET

VB & VB.NET

WebConfig特殊字符的转义

Web.Config默认编码格式为UTF-8,对于XML文件,要用到实体转义码来替换。对应关系如下:

字符

转义码

& 符号 & &
单引号 '
双引号 "
大于 > >
小于 < &lt;
 

App.config:

 

 <?xml version="1.0" encoding="utf-8" ?>
 <configuration>
     <startup> 
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
     </startup>
   <connectionStrings>
     <add name="DBconnString" connectionString="Data Source=.;Initial Catalog=MyTest123456;User ID=sa;PassWord=123&456"/>
   </connectionStrings>
 </configuration>

 

由于数据库连接的密码中含有特殊字符”&”,编译时出现如下如下错误信息:

显然编译器不认识”&456″,怎么解决呢,总不能更换密码吧?

事实上App.config是xml文件,在xml文件中特殊字符要进行HTML转义。

HTML中<,>,&等有特殊含义(<,>,用于链接签,&用于转义),不能直接使用。这些符号是不显示在我们最终看到的网页里的,那如果我们希望在网页中显示这些符号,就要用到HTML转义字符串(Escape Sequence)了

 


HTML特殊转义字符列表

 

最常用的字符实体

显示     说明     实体名称     实体编号

 

         空格     &nbsp;     &#160;

<         小于     &lt;      &#60;

>      大于    &gt;      &#62;

&      &符号    &amp;     &#38;

“      双引号    &quot;     &#34;

©      版权    &copy;    &#169;

®    已注册商标    &reg;    &#174;

™    商标(美国)    ™    &#8482;

×    乘号      &times;    &#215;

÷     除号      &divide;    &#247;

 

所以只要把”&”进行转义就可以了,将PassWord改为PassWord=123&amp;456″成功通过编译。

 

Microsoft Chart Controls

.NET 3.5 发布功能强大的新控件(Winform&WebForm) —— Chart

前言

11月25号,Scott在博客上发布了基于.NET Framework 3.5 SP1的图表控件——Chart,可在WinForm和WebForm下使用!并同时提供了大量的示例…

继续阅读

防止对 Visual Basic .NET 或 C# 代码进行反相工程

摘要

.NET 体系结构的优势之一在于,利用该体系结构构建的程序集包含很多有用的信息,使用中间语言反汇编程序 ILDASM 即可恢复这些信息。但是这样会带来另一个问题,就是可以访问您的二进制代码的人能够以非常近似的手段恢复原始源代码。作者将在文中介绍程序模糊处理,该处理可作为一种阻止反相工程的手段。此外,他们还将讨论可用的不同类型的模糊处理技术,并示范 Visual Studio .NET 2003 中包含的新模糊处理工具。 继续阅读

FTP Upload and FTP Download with VBScript

While googling around the other day I noticed that lots of people are searching for a way to FTP files with VBScript. After looking for a while at the solutions to do this, it was clear that no real easy, free way of FTP uploading and downloading files was currently available. There are downloadable components that would present a programable API. But these are costly, and you’d have to install them. So seeing the need I decided to whip up a couple of functions that would preform some basic uploading and downloading. 继续阅读

VB中通过WMI控制DNS服务器,可在ASP中调用

VB中通过WMI控制DNS服务器,可在ASP中调用

在VB中要使用Scripting API for WMI,必须引用 Microsoft WMI Scripting V1.1 Library

下面介绍Scripting API For WMI的几个对象

SWbemLocator——用于取得SWbemServices对象,他代表了本地或远程计算机上名字空间的一个连接。
SWbemService——代表名字空间的一个连接,可用于处理它的部件
SWbemObject——代表一个单独的类定义或一个对象实例
SWbemOjbectSet——包括SWbemObject的集合 继续阅读

OCS 2007 Backup Script

OCS 2007 Backup Script

One of the more useful items from the OCS 2007 Resource Kit book was the extras disc that contained a few Excel worksheets on setting up backups for different types of servers. Using those worksheets I created a script that automates some of the backup process for a standard edition server. I tried to make the script fairly configurable as far as file locations and naming conventions, but feel free to change it to suit your needs. What happens is this:

  • A SQL backup job script is created with options for a full backup that overwrites the previous one.
  • A scheduled task is created that backs up the global and pool-level settings for OCS.
  • A scheduled task is created that backs up the machine-level settings for OCS.
  • A scheduled task is created that runs the SQL backup job script.

All of the files from these tasks are dumped into a single folder of your choosing on a nightly basis. At that point you can do what you like with the contents. You could schedule your backup program to simply pick up this folder on a regular schedule or you could create another scheduled task that copies the folder to a file share on another machine. Just make sure you’re saving that folder collection somewhere else and you should be fine. 继续阅读

.NET平台下Web树形结构程序设计

概述

TreeView是一个重要的控件,无论是在VB.NET,C# 还是VB、Delphi等各种 语言中,都充当了导航器的作用。在实际工作中,很多情况下需要将TreeView与数据库进行连接,以填充其节点。在Windows Form和 Web Form中,我们可以用TreeView来显示树形结构,如显示目录树、显示地区、分类显示商品等。可以说,在大部分软件的开发 中,TreeView都是一个不可缺少的展示控件。因此,树形结构的设计就成了软件开发人员一个永恒的话题。 继续阅读