测试某个变量为空时,能否将null写入到数据库,还需不需要对空单独做处理。ID为空时,能否打印到控制台上。

测试结果:

测试结果为爬虫ID为空时,能将null写入到数据库,在数据库中没有任何值,不需额外做处理。

还可以读取数据库中的字段值为null记录。都不需额外处理。

还可以将null直接打印到控制台,显示到控制台上的内容为空。

代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ToolManagement
{
class TestForCrawlIDBeingNull
{
// 测试为爬虫ID为空时,null仍然可以打印,只不过不显示。
//写入数据库也可以将null写入,
static void Main(string[] args)
{
string temp = "Finished-C-A62";
string[] split = temp.Split(new Char[] { '-' });

ToolStateDAO toolState
= new ToolStateDAO();
toolState.WriteResult(
0, split[1].Substring(1), split[2].Substring(1));
Console.WriteLine(
"split数组是:{0}{1}{2}",split[0],split[1],split[2]);
Console.WriteLine(
"下面读取结果数据库结果");

string a = toolState.ReadCrawlerID(0);
Console.WriteLine(a);

string b = toolState.ReadDetectID(0);
Console.WriteLine(b);

Console.ReadLine();
}
}
}

 

posted @ 2010-08-25 17:29  thinking and coding  阅读(431)  评论(0编辑  收藏  举报