小弟因为需要,将部分vb.net的代码转换成c#,代码如下:
    //返回1存在,0不存在
strCheckSql = "if objectproperty(object_id('"+ SqlTableName +"'), 'IsUserTable') = 1 select 1 else select 0";
SqlConnection  CheckSqlConn = SqlConnDB;
CheckSqlConn.Open();
DataTable CheckDS;
SqlDataAdapter CheckDA = new SqlDataAdapter(strCheckSql, CheckSqlConn);
      
CheckDA.Fill(CheckDS); //这里显示错误   strCheckValue = CheckDS.Rows[0];//这里如何得到值呢?vb.net中是 strCheckValue = CheckDS.Rows(0).Item(0),在这里就不行了????
小弟不熟悉c#,请大家帮忙!!!!谢谢。

解决方案 »

  1.   

    //DataTable CheckDS;
    //CheckDA.Fill(CheckDS); //这里显示错误
    DataSet dsCheck = new DataSet();
    CheckDA.Fill(dsCheck);strCheckValue = dsCheck.Table[0].Row["行号"]["列号"].ToString();
      

  2.   

    SqlCommand selectcommand=new SqlCommand();
    strCheckSql = "if objectproperty(object_id('"+ SqlTableName +"'), 'IsUserTable') = 1 select 1 else select 0";             selectcommand.CommandText=strCheckSql ;
                 selectcommand.Connection=this.sqlConnection1;
    this.sqlConnection1.Open();
                string str1= selectcommand.ExecuteScalar().ToString();
                this.sqlConnection1.Close();
      

  3.   

    http://www.developerfusion.com/utilities/convertcsharptovb.aspx去转换一下.