protected void imgpath_check(Object sender, EventArgs e)
{
rc_id=Session["rc_id"].ToString();
tablename="rc_info";  //数据库里的表 try
{ string strconn = ConfigurationSettings.AppSettings["SqlConnectionString"];
SqlConnection myconn=new SqlConnection(strconn);
'vb的 myconn.Open();
dim cmd as SqlDataAdapter  =new SqlDataAdapter  ("select flag from rc_info where name='"+ name +"'",myconn)
dim dst as dataset=new dataset()
cmd.fill(dst)
if( dst.tables(0).rows(0)("列值").tostring )
{
                               
}
else  
{
  
}

myconn.Close();
} catch(Exception)
{

}         }

解决方案 »

  1.   

    protected void imgpath_check(Object sender, EventArgs e)
    {
    rc_id=Session["rc_id"].ToString();
    tablename="rc_info";  //数据库里的表 try
    { string strconn = ConfigurationSettings.AppSettings["SqlConnectionString"];
    SqlConnection myconn=new SqlConnection(strconn);
                               selcetCmd = "";
                                SqlCommand myCommand = SqlCommand(selectCmd,myconn);
    myconn.Open();
                                SqlDataReader myReader = myCommand.ExcuteReader(CommandBehavior.CloseConnection);
                                while(myReader.Read())
    {
                                 if(myReader.IsDBNull()
    {}
    else
    {})
    }
     }
      

  2.   

    try:string strconn = ConfigurationSettings.AppSettings["SqlConnectionString"];
    SqlConnection myconn=new SqlConnection(strconn);
    SqlCommand cmd=new SqlCommand("select 产品图片目录 from "+tablename+" where 用户ID="+rc_id,myconn);
    myconn.Open();
    object obj=myconn.ExecuteScalar();
    if(obj==DBNull.Value){
    //字段值是null
    }
    else{
    //不是null
    }
    myconn.Close();--------------------------------
    AspNetPager 免费分页控件4.2版发布,同时发布最新源代码,欢迎下载:http://www.webdiyer.com
      

  3.   

    if isdbnull(drow("id")) then
    ..
    else
     end if
      

  4.   

    To : webdiyer(陕北吴旗娃) 我编译生成的时候,vs.net 报告说:c:\inetpub\wwwroot\upload_images\guan_upimg_thumnail.aspx.cs(66): “System.Data.SqlClient.SqlConnection”并不包含对“ExecuteScalar”的定义怎么办?谢谢
      

  5.   

    晕,应该是cmd.ExecuteScalar(),对不起啊,一时大意写错了!!
      

  6.   

    多谢!现在vs.net 不报错了,生成通过了改后的代码如下:protected void imgpath_check(Object sender, EventArgs e)
    {
    rc_id=Session["rc_id"].ToString();
    tablename="rc_info"; try
    {
    string strconn = ConfigurationSettings.AppSettings["SqlConnectionString"];
    SqlConnection myconn=new SqlConnection(strconn);
    SqlCommand cmd=new SqlCommand("select 产品图片目录 from "+tablename+" where 编号="+rc_id,myconn);
    myconn.Open();
    object obj=cmd.ExecuteScalar();
    if(obj==DBNull.Value)
    {
    this.Label1.Text="空!";  //字段值是null
    }
    else
    {
    this.Label1.Text="不空!";  //不是null
    }
    myconn.Close();

    } catch(Exception)
    {

    }         }
    但是还有一点就是 lable1 不显示信息,我在调试一下吧,如果不行,再请教。先给分,我先下了,明天再来!谢谢
      

  7.   

    试试把 if(obj==DBNull.Value) 改为:if(obj==DBNull.Value||obj==null)