string.Format , object[] args 使用

string sql = "insert into TableA values('{0}','{1}','{2}',GetDate(),'{3}'  ";
       sql = string.Format(sql, apiCompany, forCompany, apiName, xmlDate);
       sqlHelper.ExcuteNonequery(sql);

 

 

string sql = string.Empty;
 
object[] args = new object[]
{
     Company,
     sku,
     altSku,
     "1",
     "Interface",
     System.DateTime.Now
};
 
sql += string.Format(@"INSERT INTO TableB(COMPANY,SKU,ALTSKU,Active,add_usr,add_date)
                                   VALUES(N'{0}',N'{1}',N'{2}',N'{3}',N'{4}','{5}');", args);
sqlHelper.ExcuteNonequery(sql);

你可能感兴趣的:(string.Format)