sql语句字符串拼接的两种方法 SQL Server

    xiaoxiao2026-05-14  10

                String ProductionProduct = temp.Rows[i][3].ToString().Trim();                     //StringBuilder Sql2 = new StringBuilder();                     //Sql2.Append("select top 1 [ProductID] from [Product] where [productname] =");                     //Sql2.Append("N'" + ProductionProduct + "';");                     //String sql22 = Sql2.ToString();                     String sql2 = @"select [ProductID] from [Product] where [productname] =N'"+ ProductionProduct+ "'";                     List< ProductModel > res2 = db.Database.SqlQuery<ProductModel >(sql2).ToList();                     string ProductID = string.Empty;                     foreach ( ProductModel productname in res2)                     {                         ProductID = String.Format( "{0}" , productname.ProductID);                     } 将数据库中字段为空的赋值为0 update Material set MaterialTypeID='0' where MaterialTypeID='' or MaterialTypeID is NULL
    转载请注明原文地址: https://ju.6miu.com/read-1309658.html
    最新回复(0)