字符串格式化出错
String str = String.Format( "insert into Plan(Name,ContentKind,StockPlan,StockFact,Phase,PhaseKind,ActWay,TimeFrom,TimeTo,Days,Source,FeeKind,PactSum,PhaseBudget,NWBudget,UnSet) values( '{0} ', '{1} ', '{2} ', '{3} ', '{4} ', '{5} ', '{6} ', '{7:d} ', '{8:d} ', '{9} ', '{10} ', '{11} ', '{12} ', '{13} ', '{14} ', '{15} ') ",
comboBoxName.Text, textBoxContent.Text,comboBoxStockPlan.Text,comboBoxStockFact.Text,
comboBoxPhase.Text,comboBoxPhaseKind.Text,comboBoxFactKind.Text,tmF.Date, tmT.Date,
Int32.Parse(textBoxDays.Text),textBoxSource.Text, comboBoxFeeKind.Text,
Int32.Parse(textBoxPactSum.Text) ,Int32.Parse(textBoxPhaseBudget.Text),
textBoxPhaseBudget.Text, textBoxUnSet.Text);
执行时报错,说是字符串格式化错误!
帮忙分析一下!
谢谢
------解决方案--------------------晕,你行啊,这么多个
------解决方案--------------------如果参数个数正确,String.Format应该不会错,可能出错的是Int32.Parse后面的参数。
------解决方案--------------------你最好分几段格式化连接字符串,这么多个,还得一个个的数哦
从性能上考虑,太长了,最好使用 StringBuilder
------解决方案--------------------String str = = String.Format( "insert into Plan(Name,ContentKind,StockPlan,StockFact,Phase,PhaseKind,ActWay, " _
+ "TimeFrom,TimeTo,Days,Source,FeeKind,PactSum,PhaseBudget,NWBudget,UnSet) " _
+ "values( '{0} ', '{1} ', '{2} ', '{3} ', '{4} ', '{5} ', '{6} ', '{7:d} ', '{8:d} ', '{9} ', '{10} ', '{11} ', '{12} ', '{13} ', '{14} ', '{15} ') ", _
" ", " ", " ", " ", _
" ", " ", " ", Now, Now, _
Int32.Parse( "1 "), " ", " ", _
Int32.Par