<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Louis Han Life Log &#187; 学习心得</title>
	<atom:link href="http://louishan.com/articles/category/study/feed" rel="self" type="application/rss+xml" />
	<link>http://louishan.com</link>
	<description>Life will find its way out!</description>
	<lastBuildDate>Tue, 07 Feb 2012 00:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SQL Server 2005：error 0 - 管道的另一端上无任何进程error 40 - 无法打开到 SQL Server 的连接</title>
		<link>http://louishan.com/articles/sql-server-2005-error-0-and-error-40.html</link>
		<comments>http://louishan.com/articles/sql-server-2005-error-0-and-error-40.html#comments</comments>
		<pubDate>Tue, 28 Jun 2011 00:00:00 +0000</pubDate>
		<dc:creator>Louis Han</dc:creator>
				<category><![CDATA[学习心得]]></category>
		<category><![CDATA[error 0]]></category>
		<category><![CDATA[error 40]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[外围应用配置器]]></category>
		<category><![CDATA[数据库]]></category>

		<guid isPermaLink="false">http://louishan.com/articles/sql-server-2005-error-0-and-error-40.html</guid>
		<description><![CDATA[&#160;&#160;&#160;&#160;&#160;&#160;&#160; 程序调试的时候，因为数据库服务器装在本机，SQL Server 连接字符串一直将 Provider 设置为 “(local)”，发布程序的时候为了在不同机器进行测试，修改成了本机的 IP 地址，可是却出现了数据库连接错误。连续执行两次连接数据库操作，出现的错误提示如下：



<span class="readmore"><a href="http://louishan.com/articles/sql-server-2005-error-0-and-error-40.html" title="SQL Server 2005：error 0 - 管道的另一端上无任何进程error 40 - 无法打开到 SQL Server 的连接">阅读全文——共820字</a></span>]]></description>
			<content:encoded><![CDATA[<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; 程序调试的时候，因为数据库服务器装在本机，SQL Server 连接字符串一直将 Provider 设置为 “(local)”，发布程序的时候为了在不同机器进行测试，修改成了本机的 IP 地址，可是却出现了数据库连接错误。连续执行两次连接数据库操作，出现的错误提示如下：</p>
<ul>
<li>已成功与服务器建立连接，但是在登录前的握手期间发生错误。在连接到 SQL Server 2005 时，在默认的设置下 SQL Server 不允许远程连接可能会导致此失败。（provider: 命名管道提供程序, error: 0 - 管道的另一端上无任何进程。） </li>
<li>在建立与服务器的连接时出错。在连接到 SQL Server 2005 时，在默认的设置下 SQL Server 不允许远程连接可能会导致此失败。（provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接） </li>
</ul>
<p align="center"><img src="http://api.photoshop.com/v1.0/accounts/2ef56cf9f72d4754b1f9e2fe822f3cd4/assets/7f5725241dc94518ba3701420ed87e08" width="550" height="175" /></p>
<p>根据网上收集到的资料修改情况如下：</p>
<p>打开 SQL Server 2005 的 SQL Server Management Studio，</p>
<p>①在对象资源管理器的数据库服务器上右键选择属性，在打开的“服务器属性”窗口左侧树形菜单，点击“安全性”，在打开的右侧面板中“服务器身份验证”一项，点选“SQL Server 和 Windows 身份验证模式(S)”；</p>
<p align="center"><img src="http://api.photoshop.com/v1.0/accounts/2ef56cf9f72d4754b1f9e2fe822f3cd4/assets/17f82b409ca54e06bd1d683108a1e299" width="524" height="315" /></p>
<p>②在对象资源管理器树形菜单中，展开“安全性→登录名→sa”，在打开的登录属性窗口选择“状态”，点选右侧的“登录”选项为“启用”状态；</p>
<p align="center"><img src="http://api.photoshop.com/v1.0/accounts/2ef56cf9f72d4754b1f9e2fe822f3cd4/assets/7e02693435d44eab8b0c2659b1620cbb" width="550" height="302" /></p>
<p>实际上上面两项默认设置就是如此，如果安装之后没有修改，不需要执行上述两项操作，接下来执行，</p>
<p>③在系统开始菜单，选择“Microsoft SQL Server 2005→配置工具→SQL Server外围应用配置器”，打开配置窗口，点击窗口下方的“服务和连接的外围应用配置器”链接打开配置窗口，点击左侧树形菜单“MSSQLSERVER→Database Engine→远程连接”，右侧选择“本地连接和远程连接（仅适用TCP/IP）”。</p>
<p align="center"><img src="http://api.photoshop.com/v1.0/accounts/2ef56cf9f72d4754b1f9e2fe822f3cd4/assets/b58f34b62bd0472885e648d73bf9b97c" width="550" height="328" /></p>
<p>设置完成，重启 SQL Server 服务，搞定。</p>
<h3>Related Posts</h3><ul><li><a href="http://louishan.com/articles/vs2005-csharp-recursion-binding-treeview-in-winform.html" title="VS2005 C#动态递归绑定TreeView（WinForm） 2011.05.31">VS2005 C#动态递归绑定TreeView（WinForm）</a>(34)</li>
<li><a href="http://louishan.com/articles/vs2005-csharp-connect-access-database-with-password.html" title="VS2005 C#连接带密码的Access数据库 2011.05.23">VS2005 C#连接带密码的Access数据库</a>(72)</li>
<li><a href="http://louishan.com/articles/weather-warmed-up.html" title="天气转暖，欣喜 2008.04.15">天气转暖，欣喜</a>(0)</li>
<li><a href="http://louishan.com/articles/sqlserver-database-log-shrink.html" title="解析SQLServer事务日志压缩与删除的方法 2008.04.11">解析SQLServer事务日志压缩与删除的方法</a>(0)</li>
<li><a href="http://louishan.com/articles/last-final-exam-fight.html" title="明天最后上战场 2008.01.9">明天最后上战场</a>(0)</li>
</ul><hr />
<p><small>© Louis for <a href="http://louishan.com">Louis Han Life Log</a>, 2011. |
<a href="http://louishan.com/articles/sql-server-2005-error-0-and-error-40.html">Permalink</a> |
<a href="http://louishan.com/articles/sql-server-2005-error-0-and-error-40.html#comments">22 comments</a> |
<br/>
Post tags: <a href="http://louishan.com/articles/tag/error-0" rel="tag">error 0</a>, <a href="http://louishan.com/articles/tag/error-40" rel="tag">error 40</a>, <a href="http://louishan.com/articles/tag/sql-server" rel="tag">SQL Server</a>, <a href="http://louishan.com/articles/tag/%e5%a4%96%e5%9b%b4%e5%ba%94%e7%94%a8%e9%85%8d%e7%bd%ae%e5%99%a8" rel="tag">外围应用配置器</a>, <a href="http://louishan.com/articles/tag/%e6%95%b0%e6%8d%ae%e5%ba%93" rel="tag">数据库</a><br/>
订阅(Subscribe)：<a href="http://louishan.com/feed">FeedBurner</a> | <a href="http://feed.feedsky.com/louishan">FeedSky</a> 
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://louishan.com/articles/sql-server-2005-error-0-and-error-40.html/feed</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>VS2005 C#程序部署到没有安装.net的机器</title>
		<link>http://louishan.com/articles/vs2005-csharp-deploy-application-to-system-without-dotnet.html</link>
		<comments>http://louishan.com/articles/vs2005-csharp-deploy-application-to-system-without-dotnet.html#comments</comments>
		<pubDate>Tue, 21 Jun 2011 00:00:00 +0000</pubDate>
		<dc:creator>Louis Han</dc:creator>
				<category><![CDATA[学习心得]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[vs2005]]></category>
		<category><![CDATA[卸载程序]]></category>
		<category><![CDATA[安装部署项目]]></category>

		<guid isPermaLink="false">http://louishan.com/articles/vs2005-csharp-deploy-application-to-system-without-dotnet.html</guid>
		<description><![CDATA[&#160;&#160;&#160;&#160;&#160;&#160;&#160; 要将C#程序部署到没有安装 .net Framework 2.0 的机器上，打包方法总结如下：

1.新建安装部署项目：     &#160;&#160;&#160;&#160;&#160;&#160;&#160; 点击新建项目，选择：其他项目类型-&#62;安装与部署-&#62;安装向导(安装项目也一样)，然后点击确定。

<span class="readmore"><a href="http://louishan.com/articles/vs2005-csharp-deploy-application-to-system-without-dotnet.html" title="VS2005 C#程序部署到没有安装.net的机器">阅读全文——共1075字</a></span>]]></description>
			<content:encoded><![CDATA[<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; 要将C#程序部署到没有安装 .net Framework 2.0 的机器上，打包方法总结如下：</p>
<p><strong>1.新建安装部署项目：</strong>     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 点击新建项目，选择：其他项目类型-&gt;安装与部署-&gt;安装向导(安装项目也一样)，然后点击确定。</p>
<p align="center"><img src="http://api.photoshop.com/v1.0/accounts/2ef56cf9f72d4754b1f9e2fe822f3cd4/assets/2973ea0585d94b0bbb8893e9bc709d70" width="520" height="346" /></p>
<p><strong>2.安装向导：</strong>     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 第一步点击确定后出现安装向导，选择：创建用于Windows应用程序的安装程序（S）。一路点击下一步，或者直接点击完成。最终会在当前的解决方案中添加一个名称为“Setup1”的安装项目。</p>
<p><strong>3.开始制作：</strong>     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 安装向导完成后进入项目文件夹，在窗口“文件系统（Setup1）”下，有三个文件夹：“应用程序文件夹”、“用户的‘程序’菜单”、“用户桌面”。     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 双击“应用程序文件夹”在右边的空白处右击，选择添加-&gt;文件，将你的做的应用程序的可执行文件和相应的类库和组件添加进来。然后右击你的文件，创建快捷方式，修改为你希望的名称，然后把快捷方式分别复制或剪切到左边的“用户的‘程序’菜单”和“用户桌面”中。这样安装程序安装完成后会在 “开始-&gt;所有程序”和“桌面”上生成程序的快捷方式。也可以直接在“用户的‘程序’菜单”和“用户桌面”相应目录下新建快捷方式，然后定位到你的文件。</p>
<p align="center"><img src="http://api.photoshop.com/v1.0/accounts/2ef56cf9f72d4754b1f9e2fe822f3cd4/assets/bb64cd43912f4a84ac68a11bfd3016fe" width="520" height="173" /></p>
<p><strong>4.修改安装目录：</strong>     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 编辑“应用程序文件夹”属性，将属性中的“DefaultLocation”的路径中的“[Manufacturer]”去掉，不然的话做好的安装程序默认安装目录会是“C:\Program Files\你的用户名\安装解决方案名称”。</p>
<p align="center"><img src="http://api.photoshop.com/v1.0/accounts/2ef56cf9f72d4754b1f9e2fe822f3cd4/assets/ad070326938d4974ab1e566da5ebc69e" width="221" height="338" /></p>
<p><strong>5.关联必备组件：</strong>     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 打开解决方案管理器，右击解决方案名称，在“Setup1”属性页，选择-&gt;“系统必备”，在打开的系统必备页中，在“指定系统必备安装组件的位置”选择-&gt;“从与我的应用程序相同的位置下载系统必备组件(D)”。选上以后，在生成的安装文件包中包含 .Net Framework 组件。</p>
<p align="center"><img src="http://api.photoshop.com/v1.0/accounts/2ef56cf9f72d4754b1f9e2fe822f3cd4/assets/12d11598687f4ede83fac5b83a6c7c80" width="520" height="378" /></p>
<p><strong>6.添加卸载功能：</strong>     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 在安装项目“应用程序文件夹”，添加“X:\windows\system32”文件夹下的“msiexec.exe”，为了直观改名为“Uninstall.exe”，创建一个快捷方式放到“用户的‘程序’菜单”。鼠标左键单击部署项目，在属性标签中找到“ProductCode”，在卸载程序快捷方式的属性中，填写“/x {ProductCode}”（不含引号），即可生成带有卸载功能的安装程序（调用系统卸载功能）。</p>
<p align="center"><img src="http://api.photoshop.com/v1.0/accounts/2ef56cf9f72d4754b1f9e2fe822f3cd4/assets/af8b23c46d914caeb22f4c9abde3f397" width="221" height="338" />&#160; <img src="http://api.photoshop.com/v1.0/accounts/2ef56cf9f72d4754b1f9e2fe822f3cd4/assets/feac9e7a96db482aa5a01fdbecec36ca" width="221" height="338" /></p>
<p><strong>7.生成安装文件：</strong>     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 在 VS 2005 菜单选择：生成-&gt;生成解决方案，打开解决方案文件夹下的Release/Debug文件夹，就可以看到生成的安装文件 Setup1.exe 和 Setup1.msi 了。</p>
<p>（感谢Google搜索到的众多参考资料作者）</p>
<h3>Related Posts</h3><ul><li><a href="http://louishan.com/articles/vs2005-csharp-recursion-binding-treeview-in-winform.html" title="VS2005 C#动态递归绑定TreeView（WinForm） 2011.05.31">VS2005 C#动态递归绑定TreeView（WinForm）</a>(34)</li>
<li><a href="http://louishan.com/articles/vs2005-csharp-connect-access-database-with-password.html" title="VS2005 C#连接带密码的Access数据库 2011.05.23">VS2005 C#连接带密码的Access数据库</a>(72)</li>
<li><a href="http://louishan.com/articles/vs-2005-debug.html" title="VS2005实时调试的禁用和恢复 2009.06.30">VS2005实时调试的禁用和恢复</a>(0)</li>
<li><a href="http://louishan.com/articles/dotnet-date-format.html" title=".NET 中日期和时间的格式化处理 2008.06.20">.NET 中日期和时间的格式化处理</a>(0)</li>
<li><a href="http://louishan.com/articles/vs2005-microsoft-build-engine.html" title="VS2005未能加载文件或程序集Microsoft.Build.Engine 2008.06.1">VS2005未能加载文件或程序集Microsoft.Build.Engine</a>(0)</li>
<li><a href="http://louishan.com/articles/some-dropdownlist-updatepanel-solutions.html" title="又解决了几个问题：DropdownList和UpdatePanel 2008.04.23">又解决了几个问题：DropdownList和UpdatePanel</a>(0)</li>
<li><a href="http://louishan.com/articles/iis-aspnet-20-debug.html" title="IIS + ASP.NET 2.0调试过程 2008.04.10">IIS + ASP.NET 2.0调试过程</a>(0)</li>
</ul><hr />
<p><small>© Louis for <a href="http://louishan.com">Louis Han Life Log</a>, 2011. |
<a href="http://louishan.com/articles/vs2005-csharp-deploy-application-to-system-without-dotnet.html">Permalink</a> |
<a href="http://louishan.com/articles/vs2005-csharp-deploy-application-to-system-without-dotnet.html#comments">40 comments</a> |
<br/>
Post tags: <a href="http://louishan.com/articles/tag/net" rel="tag">.NET</a>, <a href="http://louishan.com/articles/tag/csharp" rel="tag">csharp</a>, <a href="http://louishan.com/articles/tag/vs2005" rel="tag">vs2005</a>, <a href="http://louishan.com/articles/tag/%e5%8d%b8%e8%bd%bd%e7%a8%8b%e5%ba%8f" rel="tag">卸载程序</a>, <a href="http://louishan.com/articles/tag/%e5%ae%89%e8%a3%85%e9%83%a8%e7%bd%b2%e9%a1%b9%e7%9b%ae" rel="tag">安装部署项目</a><br/>
订阅(Subscribe)：<a href="http://louishan.com/feed">FeedBurner</a> | <a href="http://feed.feedsky.com/louishan">FeedSky</a> 
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://louishan.com/articles/vs2005-csharp-deploy-application-to-system-without-dotnet.html/feed</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>VS2005 C#动态递归绑定TreeView（WinForm）</title>
		<link>http://louishan.com/articles/vs2005-csharp-recursion-binding-treeview-in-winform.html</link>
		<comments>http://louishan.com/articles/vs2005-csharp-recursion-binding-treeview-in-winform.html#comments</comments>
		<pubDate>Tue, 31 May 2011 00:00:00 +0000</pubDate>
		<dc:creator>Louis Han</dc:creator>
				<category><![CDATA[学习心得]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[TreeView]]></category>
		<category><![CDATA[vs2005]]></category>
		<category><![CDATA[WinForm]]></category>
		<category><![CDATA[数据库]]></category>
		<category><![CDATA[递归绑定]]></category>

		<guid isPermaLink="false">http://louishan.com/articles/vs2005-csharp-recursion-binding-treeview-in-winform.html</guid>
		<description><![CDATA[&#160;&#160;&#160;&#160;&#160;&#160;&#160; 继续分享我在写程序当中的一些心得体会。其实早在学校的时候写博客，就经常分享一些自己的学习所得，不过那时候写程序都是 WebForm 的，基本上没有写过 WinForm 的程序。现在不同了，工作中用到 web 程序的机会不多，反而桌面端的程序用的多了，只好改行做 WinForm 程序了。

&#160;&#160;&#160;&#160;&#160;&#160;&#160; 我定义了一个单位数据表，用来存储单位信息，程序运行时要从数据库里取出单位信息动态绑定在 TreeView 树形菜单。这个数据表的结构是这样的：

<span class="readmore"><a href="http://louishan.com/articles/vs2005-csharp-recursion-binding-treeview-in-winform.html" title="VS2005 C#动态递归绑定TreeView（WinForm）">阅读全文——共2008字</a></span>]]></description>
			<content:encoded><![CDATA[<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; 继续分享我在写程序当中的一些心得体会。其实早在学校的时候写博客，就经常分享一些自己的学习所得，不过那时候写程序都是 WebForm 的，基本上没有写过 WinForm 的程序。现在不同了，工作中用到 web 程序的机会不多，反而桌面端的程序用的多了，只好改行做 WinForm 程序了。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; 我定义了一个单位数据表，用来存储单位信息，程序运行时要从数据库里取出单位信息动态绑定在 TreeView 树形菜单。这个数据表的结构是这样的：</p>
<p align="center"><img src="http://api.photoshop.com/v1.0/accounts/2ef56cf9f72d4754b1f9e2fe822f3cd4/assets/7d7e0735fbde479eb42a27891d2580f7/renditions/fullsize.jpg" width="321" height="311" /></p>
<p>下面是相关的程序代码：</p>
<pre></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px">  1:         OleDbConnection connection = <span style="color: #0000ff">null</span>;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px">  2:         OleDbCommand command = <span style="color: #0000ff">null</span>;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px">  3:         OleDbDataAdapter dataAdapter = <span style="color: #0000ff">null</span>;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px">  4:         <span style="color: #0000ff">string</span> connectionString = &quot;<span style="color: #8b0000">Provider=Microsoft.Jet.OLEDB.4.0;Data Source = </span>&quot; +
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px">  5:                     Application.StartupPath + @&quot;<span style="color: #8b0000">\Database\TEST.mdb</span>&quot; + &quot;<span style="color: #8b0000">; Jet OleDb:Database Password = 12345</span>&quot;;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px">  6:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px">  7:         <span style="color: #0000ff">private</span> <span style="color: #0000ff">void</span> FormMain_Load(<span style="color: #0000ff">object</span> sender, EventArgs e)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px">  8:         {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px">  9:                 <span style="color: #008000">//初始化TreeView信息</span>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 10:                 TreeViewUnit_DataBind();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 11:         }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 12:         <span style="color: #0000ff">protected</span> <span style="color: #0000ff">void</span> TreeViewUnit_DataBind()
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 13:         {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 14:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 15:             <span style="color: #008000">//初始化连接</span>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 16:             connection = <span style="color: #0000ff">new</span> OleDbConnection(connectionString);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 17:             <span style="color: #008000">//打开连接</span>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 18:             connection.Open();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 19:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 20:             <span style="color: #008000">//初始化TreeView信息</span>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 21:             <span style="color: #0000ff">this</span>.treeViewUnit.Nodes.Clear();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 22:             TreeNode root = <span style="color: #0000ff">new</span> TreeNode(&quot;<span style="color: #8b0000">单位列表</span>&quot;);     <span style="color: #008000">//添加根节点</span>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 23:             root.Expand();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 24:             <span style="color: #0000ff">this</span>.treeViewUnit.Nodes.Add(root);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 25:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 26:             <span style="color: #0000ff">string</span> sqlStr = &quot;<span style="color: #8b0000">SELECT * FROM UNIT WHERE SuperiorID = 0</span>&quot;;  <span style="color: #008000">//选择大单位节点</span>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 27:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 28:             dataAdapter = <span style="color: #0000ff">new</span> OleDbDataAdapter(sqlStr, connection);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 29:             DataSet ds = <span style="color: #0000ff">new</span> DataSet();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 30:             dataAdapter.Fill(ds);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 31:             DataView dv = ds.Tables[0].DefaultView;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 32:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 33:             <span style="color: #0000ff">foreach</span> (DataRowView row <span style="color: #0000ff">in</span> dv)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 34:             {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 35:                 <span style="color: #0000ff">string</span> unitName = row[&quot;<span style="color: #8b0000">Unit_Name</span>&quot;].ToString().Trim();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 36:                 <span style="color: #0000ff">int</span> unitID = Convert.ToInt32(row[&quot;<span style="color: #8b0000">ID</span>&quot;].ToString().Trim());
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 37:                 TreeNode unit=<span style="color: #0000ff">new</span> TreeNode(unitName);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 38:                 unit.Expand();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 39:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 40:                 TreeView_AddChildNodes(unit, unitID);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 41:                 <span style="color: #0000ff">this</span>.treeViewUnit.Nodes.Add(unit);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 42:             }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 43:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 44:             <span style="color: #008000">//关闭连接</span>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 45:             connection.Close();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 46:         }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 47:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 48:         <span style="color: #008000">//TreeView递归添加子节点</span>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 49:         <span style="color: #0000ff">protected</span> <span style="color: #0000ff">void</span> TreeView_AddChildNodes(TreeNode node, <span style="color: #0000ff">int</span> nodeID)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 50:         {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 51:             <span style="color: #0000ff">string</span> sqlStr=&quot;<span style="color: #8b0000">SELECT * FROM UNIT WHERE SuperiorID = </span>&quot; + nodeID;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 52:             dataAdapter = <span style="color: #0000ff">new</span> OleDbDataAdapter(sqlStr, connection);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 53:             DataSet ds = <span style="color: #0000ff">new</span> DataSet();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 54:             dataAdapter.Fill(ds);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 55:             DataView dv = ds.Tables[0].DefaultView;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 56:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 57:             <span style="color: #0000ff">foreach</span> (DataRowView row <span style="color: #0000ff">in</span> dv)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 58:             {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 59:                 <span style="color: #0000ff">string</span> unitName = row[&quot;<span style="color: #8b0000">Unit_Name</span>&quot;].ToString().Trim();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 60:                 <span style="color: #0000ff">int</span> unitID = Convert.ToInt32(row[&quot;<span style="color: #8b0000">ID</span>&quot;].ToString().Trim());
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 61:                 TreeNode unit = <span style="color: #0000ff">new</span> TreeNode(unitName);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 62:                 unit.Expand();
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 63:
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 64:                 TreeView_AddChildNodes(unit, unitID);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 65:                 node.Nodes.Add(unit);
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 66:             }
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"> 67:         }</pre>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; 程序的运行结果是这样的，满足了我的需求。因为是小程序，数据也比较少，所以没有考虑数据库存储优化等等。</p>
<p align="center"><img src="http://api.photoshop.com/v1.0/accounts/2ef56cf9f72d4754b1f9e2fe822f3cd4/assets/b512158c79614405bf23c6246b5c43cc/renditions/fullsize.jpg" width="150" height="215" /></p>
<h3>Related Posts</h3><ul><li><a href="http://louishan.com/articles/vs2005-csharp-connect-access-database-with-password.html" title="VS2005 C#连接带密码的Access数据库 2011.05.23">VS2005 C#连接带密码的Access数据库</a>(72)</li>
<li><a href="http://louishan.com/articles/sql-server-2005-error-0-and-error-40.html" title="SQL Server 2005：error 0 - 管道的另一端上无任何进程error 40 - 无法打开到 SQL Server 的连接 2011.06.28">SQL Server 2005：error 0 - 管道的另一端上无任何进程error 40 - 无法打开到 SQL Server 的连接</a>(22)</li>
<li><a href="http://louishan.com/articles/vs2005-csharp-deploy-application-to-system-without-dotnet.html" title="VS2005 C#程序部署到没有安装.net的机器 2011.06.21">VS2005 C#程序部署到没有安装.net的机器</a>(40)</li>
<li><a href="http://louishan.com/articles/vs-2005-debug.html" title="VS2005实时调试的禁用和恢复 2009.06.30">VS2005实时调试的禁用和恢复</a>(0)</li>
<li><a href="http://louishan.com/articles/jvm-c-fiction.html" title="关于JVM 和C 的科普小说! [转载] 2008.07.2">关于JVM 和C 的科普小说! [转载]</a>(0)</li>
<li><a href="http://louishan.com/articles/vs2005-microsoft-build-engine.html" title="VS2005未能加载文件或程序集Microsoft.Build.Engine 2008.06.1">VS2005未能加载文件或程序集Microsoft.Build.Engine</a>(0)</li>
<li><a href="http://louishan.com/articles/some-dropdownlist-updatepanel-solutions.html" title="又解决了几个问题：DropdownList和UpdatePanel 2008.04.23">又解决了几个问题：DropdownList和UpdatePanel</a>(0)</li>
<li><a href="http://louishan.com/articles/weather-warmed-up.html" title="天气转暖，欣喜 2008.04.15">天气转暖，欣喜</a>(0)</li>
<li><a href="http://louishan.com/articles/sqlserver-database-log-shrink.html" title="解析SQLServer事务日志压缩与删除的方法 2008.04.11">解析SQLServer事务日志压缩与删除的方法</a>(0)</li>
<li><a href="http://louishan.com/articles/iis-aspnet-20-debug.html" title="IIS + ASP.NET 2.0调试过程 2008.04.10">IIS + ASP.NET 2.0调试过程</a>(0)</li>
</ul><hr />
<p><small>© Louis for <a href="http://louishan.com">Louis Han Life Log</a>, 2011. |
<a href="http://louishan.com/articles/vs2005-csharp-recursion-binding-treeview-in-winform.html">Permalink</a> |
<a href="http://louishan.com/articles/vs2005-csharp-recursion-binding-treeview-in-winform.html#comments">34 comments</a> |
<br/>
Post tags: <a href="http://louishan.com/articles/tag/c" rel="tag">c</a>, <a href="http://louishan.com/articles/tag/treeview" rel="tag">TreeView</a>, <a href="http://louishan.com/articles/tag/vs2005" rel="tag">vs2005</a>, <a href="http://louishan.com/articles/tag/winform" rel="tag">WinForm</a>, <a href="http://louishan.com/articles/tag/%e6%95%b0%e6%8d%ae%e5%ba%93" rel="tag">数据库</a>, <a href="http://louishan.com/articles/tag/%e9%80%92%e5%bd%92%e7%bb%91%e5%ae%9a" rel="tag">递归绑定</a><br/>
订阅(Subscribe)：<a href="http://louishan.com/feed">FeedBurner</a> | <a href="http://feed.feedsky.com/louishan">FeedSky</a> 
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://louishan.com/articles/vs2005-csharp-recursion-binding-treeview-in-winform.html/feed</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>VS2005 C#连接带密码的Access数据库</title>
		<link>http://louishan.com/articles/vs2005-csharp-connect-access-database-with-password.html</link>
		<comments>http://louishan.com/articles/vs2005-csharp-connect-access-database-with-password.html#comments</comments>
		<pubDate>Mon, 23 May 2011 07:09:41 +0000</pubDate>
		<dc:creator>Louis Han</dc:creator>
				<category><![CDATA[学习心得]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[vs2005]]></category>
		<category><![CDATA[数据库]]></category>

		<guid isPermaLink="false">http://louishan.com/articles/vs2005-c%e8%bf%9e%e6%8e%a5%e5%b8%a6%e5%af%86%e7%a0%81%e7%9a%84access%e6%95%b0%e6%8d%ae%e5%ba%93.html</guid>
		<description><![CDATA[&#160;&#160;&#160;&#160;&#160;&#160;&#160; 最近在写一个简单的人员管理小程序，既然是自己人用，Access 数据库就已经足够了。不过以前用VS的时候一般习惯就用微软自己的Sqlserver数据库了，对于Access的操作还是比较生疏的。

&#160;&#160;&#160;&#160;&#160;&#160;&#160; 虽然Access数据库设置的密码是明码，可以直接读取。可是为了一丁点的安全考虑，还是设置了密码，于是就碰到了第一个问题：怎么连接带密码的Access数据库？

<span class="readmore"><a href="http://louishan.com/articles/vs2005-csharp-connect-access-database-with-password.html" title="VS2005 C#连接带密码的Access数据库">阅读全文——共415字</a></span>]]></description>
			<content:encoded><![CDATA[<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; 最近在写一个简单的人员管理小程序，既然是自己人用，Access 数据库就已经足够了。不过以前用VS的时候一般习惯就用微软自己的Sqlserver数据库了，对于Access的操作还是比较生疏的。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; 虽然Access数据库设置的密码是明码，可以直接读取。可是为了一丁点的安全考虑，还是设置了密码，于是就碰到了第一个问题：怎么连接带密码的Access数据库？</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; 查了半天资料，网上到处都是垃圾信息，而且很多都是误导性的信息。经过层层筛选，终于找到了最合理的语句如下：</p>
<pre></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px"><span style="color: #0000ff">string</span>  conn= &quot;<span style="color: #8b0000">Provider=Microsoft.Jet.OLEDB.4.0;Data Source = </span>&quot; +
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px">               Application.StartupPath + @&quot;<span style="color: #8b0000">\database\test.mdb</span>&quot; +
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px">               &quot;<span style="color: #8b0000">;Jet OLEDB:Database Password=123456</span>&quot;;</pre>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; 很久没有写代码了，感觉手生得很。不知道再过几年，我的专业知识就完全忘掉了~ 一年写一次代码的悲哀啊！！</p>
<h3>Related Posts</h3><ul><li><a href="http://louishan.com/articles/vs2005-csharp-recursion-binding-treeview-in-winform.html" title="VS2005 C#动态递归绑定TreeView（WinForm） 2011.05.31">VS2005 C#动态递归绑定TreeView（WinForm）</a>(34)</li>
<li><a href="http://louishan.com/articles/sql-server-2005-error-0-and-error-40.html" title="SQL Server 2005：error 0 - 管道的另一端上无任何进程error 40 - 无法打开到 SQL Server 的连接 2011.06.28">SQL Server 2005：error 0 - 管道的另一端上无任何进程error 40 - 无法打开到 SQL Server 的连接</a>(22)</li>
<li><a href="http://louishan.com/articles/vs2005-csharp-deploy-application-to-system-without-dotnet.html" title="VS2005 C#程序部署到没有安装.net的机器 2011.06.21">VS2005 C#程序部署到没有安装.net的机器</a>(40)</li>
<li><a href="http://louishan.com/articles/vs-2005-debug.html" title="VS2005实时调试的禁用和恢复 2009.06.30">VS2005实时调试的禁用和恢复</a>(0)</li>
<li><a href="http://louishan.com/articles/tonido-cloudless-computing.html" title="Tonido：桌面上的云计算[译文44] 2009.04.12">Tonido：桌面上的云计算[译文44]</a>(0)</li>
<li><a href="http://louishan.com/articles/jvm-c-fiction.html" title="关于JVM 和C 的科普小说! [转载] 2008.07.2">关于JVM 和C 的科普小说! [转载]</a>(0)</li>
<li><a href="http://louishan.com/articles/vs2005-microsoft-build-engine.html" title="VS2005未能加载文件或程序集Microsoft.Build.Engine 2008.06.1">VS2005未能加载文件或程序集Microsoft.Build.Engine</a>(0)</li>
<li><a href="http://louishan.com/articles/some-dropdownlist-updatepanel-solutions.html" title="又解决了几个问题：DropdownList和UpdatePanel 2008.04.23">又解决了几个问题：DropdownList和UpdatePanel</a>(0)</li>
<li><a href="http://louishan.com/articles/weather-warmed-up.html" title="天气转暖，欣喜 2008.04.15">天气转暖，欣喜</a>(0)</li>
<li><a href="http://louishan.com/articles/sqlserver-database-log-shrink.html" title="解析SQLServer事务日志压缩与删除的方法 2008.04.11">解析SQLServer事务日志压缩与删除的方法</a>(0)</li>
</ul><hr />
<p><small>© Louis for <a href="http://louishan.com">Louis Han Life Log</a>, 2011. |
<a href="http://louishan.com/articles/vs2005-csharp-connect-access-database-with-password.html">Permalink</a> |
<a href="http://louishan.com/articles/vs2005-csharp-connect-access-database-with-password.html#comments">72 comments</a> |
<br/>
Post tags: <a href="http://louishan.com/articles/tag/access" rel="tag">access</a>, <a href="http://louishan.com/articles/tag/c" rel="tag">c</a>, <a href="http://louishan.com/articles/tag/vs2005" rel="tag">vs2005</a>, <a href="http://louishan.com/articles/tag/%e6%95%b0%e6%8d%ae%e5%ba%93" rel="tag">数据库</a><br/>
订阅(Subscribe)：<a href="http://louishan.com/feed">FeedBurner</a> | <a href="http://feed.feedsky.com/louishan">FeedSky</a> 
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://louishan.com/articles/vs2005-csharp-connect-access-database-with-password.html/feed</wfw:commentRss>
		<slash:comments>72</slash:comments>
		</item>
		<item>
		<title>如何维护健康(3/3)：疾病与健康</title>
		<link>http://louishan.com/articles/how-to-sustain-health-03-disease-and-health.html</link>
		<comments>http://louishan.com/articles/how-to-sustain-health-03-disease-and-health.html#comments</comments>
		<pubDate>Tue, 01 Feb 2011 00:00:00 +0000</pubDate>
		<dc:creator>Louis Han</dc:creator>
				<category><![CDATA[学习心得]]></category>
		<category><![CDATA[健康]]></category>
		<category><![CDATA[合理膳食]]></category>
		<category><![CDATA[疾病]]></category>

		<guid isPermaLink="false">http://louishan.com/articles/how-to-sustain-health-03-disease-and-health.html</guid>
		<description><![CDATA[&#160;&#160;&#160;&#160;&#160;&#160;&#160; 马上就过年了，过年难免就会吃喝玩乐，在尽情享受的同时，请一定要注意合理膳食，保持良好的身体和心理健康。这是我们的“如何维护健康“讲座最后一部分内容，希望通过这三篇文章的内容，对于您平日里注意生活方式，维护身体健康，过上积极向上的生活方式！

第三讲：疾病与健康

<span class="readmore"><a href="http://louishan.com/articles/how-to-sustain-health-03-disease-and-health.html" title="如何维护健康(3/3)：疾病与健康">阅读全文——共1018字</a></span>]]></description>
			<content:encoded><![CDATA[<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; 马上就过年了，过年难免就会吃喝玩乐，在尽情享受的同时，请一定要注意合理膳食，保持良好的身体和心理健康。这是我们的“如何维护健康“讲座最后一部分内容，希望通过这三篇文章的内容，对于您平日里注意生活方式，维护身体健康，过上积极向上的生活方式！</p>
<h6>第三讲：疾病与健康</h6>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; 人的一生中生病是难免的，只是大病，小病，不同的疾病而已，疾病本身对机体和精神都有一定的影响，要正确认识，正确对待，不但要积极配合医生治疗，而且本人要保持良好的心情，良好的心情有利于疾病的早日康复。即使患有严重的疾病，也应树立战胜疾病的信心。    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 疾病一旦发生就会带来痛苦，降低我们的生活质量，消耗金钱，甚至威胁生命，因此它让我们沮丧、不安甚至恐惧，这是一种正常的反应，对疾病的恐惧是人类自觉进行保健的动力之一。但是，我们不能仅仅沮丧、不安和恐惧，对待疾病应该有一个正确的态度。    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 1、疾病是可以预防的。大多数疾病可以通过适当的保健方式进行预防，预防疾病是一个终生的行为，预防第一，治疗第二。    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 2、疾病是可以治疗的。随着医学水平的不断提高，很多疾病可以治愈，一些不能完全治愈的也可以通过积极治疗缓解病情、减轻痛苦、提高生存质量或者延长生存期等，对一些严重的疾病灰心绝望、拒绝治疗是不恰当的。    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 3 、治病要趁早。任何疾病都有一个发生发展的过程，及早治疗可以及时终止疾病的深入发展，最大限度地减少对身体器官和功能的损害，更容易恢复健康。    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 4、不要讳疾忌医。身体有不适，要及时看医生，有些人觉得一点小小不适没关系，有些人害怕去看医生，担心万一检查出什么严重的疾病自己会承受不住。无论大意还是恐惧都是不可取的。    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 5、有些慢性病要终身治疗。像某些心脏病、高血压、糖尿病，等等，要在医生的指导下进行终生治疗。    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 6、切忌有病乱投医。治病要科学合理，要有系统性，千万不可以跟着医疗广告走，那样很可能费力、费时、费钱却得不到疗效，甚至耽误治疗。    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 7、要放宽心。病既然已经生了，过多的担心、恐惧只能对康复带来负面的影响，因此既来之则安之，以平常心视之，把心放宽些，扔掉心理包袱，积极治疗，是对待疾病的最佳心态。    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 8、治病不仅仅是医生的任务。要取得好的疗效，病人及其家人一定要和医生积极配合，共同努力。病人及其家人要相信医生，遵守医嘱，并尽可能了解自己的病情，配合治疗。    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 至此，我们不难看出，维护健康的四大基石：合理膳食、适量运动、戒烟限酒、心理平衡。</p>
<p><strong>快速链接：</strong></p>
<p><a href="http://louishan.com/articles/how-to-sustain-health-01-health-and-subhealthy.html" target="_blank"><u>如何维护健康(1/3)：健康与亚健康</u></a>    <br /><a href="http://louishan.com/articles/how-to-sustain-health-02-hygiene-and-health.html" target="_blank"><u>如何维护健康(2/3)：卫生与健康</u></a></p>
<h3>Related Posts</h3><ul><li><a href="http://louishan.com/articles/how-to-sustain-health-02-hygiene-and-health.html" title="如何维护健康(2/3)：卫生与健康 2011.01.28">如何维护健康(2/3)：卫生与健康</a>(21)</li>
<li><a href="http://louishan.com/articles/how-to-sustain-health-01-health-and-subhealthy.html" title="如何维护健康(1/3)：健康与亚健康 2011.01.26">如何维护健康(1/3)：健康与亚健康</a>(31)</li>
<li><a href="http://louishan.com/articles/1114-my-hometown-delicious-food.html" title="[11.14]我们家乡的美味小吃 2007.11.14">[11.14]我们家乡的美味小吃</a>(1)</li>
</ul><hr />
<p><small>© Louis for <a href="http://louishan.com">Louis Han Life Log</a>, 2011. |
<a href="http://louishan.com/articles/how-to-sustain-health-03-disease-and-health.html">Permalink</a> |
<a href="http://louishan.com/articles/how-to-sustain-health-03-disease-and-health.html#comments">8 comments</a> |
<br/>
Post tags: <a href="http://louishan.com/articles/tag/%e5%81%a5%e5%ba%b7" rel="tag">健康</a>, <a href="http://louishan.com/articles/tag/%e5%90%88%e7%90%86%e8%86%b3%e9%a3%9f" rel="tag">合理膳食</a>, <a href="http://louishan.com/articles/tag/%e7%96%be%e7%97%85" rel="tag">疾病</a><br/>
订阅(Subscribe)：<a href="http://louishan.com/feed">FeedBurner</a> | <a href="http://feed.feedsky.com/louishan">FeedSky</a> 
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://louishan.com/articles/how-to-sustain-health-03-disease-and-health.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

