if ()   int i =0 ;
if  ()
   int i =1 ;
   int nationid=Convert.ToInt32(ddlNational.SelectedValue.ToString())+2;
  
  SELECT TOP 1 basePrice,unitPrice FROM Freight WHERE isParcel = i AND NationalID = nationid  上面的sql 语句对吗,该怎么改啊, 
  

解决方案 »

  1.   

    int i = 0;
    if()
     i = 0;
    else if()
     i = 1;int nationid = Convert.ToInt32(ddlNational.SelectedValue.ToString())+2;
    string sql = "SELECT TOP 1 basePrice,unitPrice FROM Freight WHERE isParcel = " + i + "AND NationalID = '" + nationid  +"'";
      

  2.   

    string Sql = string.Format("SELECT TOP 1 basePrice,unitPrice FROM Freight WHERE isParcel = {0} AND NationalID = {1}",i.ToString(),nationid.ToString());
      

  3.   

     string Sql = " SELECT TOP 1 basePrice,unitPrice FROM Freight WHERE isParcel = " + i + " AND NationalID = " + nationid;   
      

  4.   

    SELECT TOP 1 basePrice,unitPrice FROM Freight WHERE isParcel = " + i + " AND NationalID = " + nationid;