未将对象引用设置到对象的实例?怎么解决?
放在:if(!Page.IsPostBack)
{
tongji();
}
如下:
private void tongji()
{
if(Request.UrlReferrer.ToString().Substring(0,20).ToString()!="http://www.ip808.com")
{
string UserHostAddress=Request.UserHostAddress ;
OpenDatabase();
string sql="insert into tongji(Cip,Ctime)values'"+UserHostAddress+"','"+System.DateTime.Now+"')";
SqlCommand cmd=new SqlCommand(sql,cn);
cmd.ExecuteNonQuery();
cn.Close();
}
}
提示这行:
if(Request.UrlReferrer.ToString().Substring(0,20).ToString()!="http://www.ip808.com")
未将对象引用设置到对象的实例
怎么解决??