gpt4 book ai didi

sql - sqlcommand.parameters.add() 和 sqlcommand.parameters.addwithvalue() 有什么区别

转载 作者:行者123 更新时间:2023-12-04 15:15:19 25 4
gpt4 key购买 nike

我们可以在将参数传递给 sql 查询时同时使用这两种方法吗?
那么它们之间有什么区别呢?

最佳答案

MSDN article on AddWithValue() 解释两者之间的差异。内是对细微差异的解释。

AddWithValue replaces the SqlParameterCollection.Add method that takes a String and an Object.

The overload of Add that takes a string and an object was deprecated because of possible ambiguity with the SqlParameterCollection.Add overload that takes a String and a SqlDbType enumeration value where passing an integer with the string could be interpreted as being either the parameter value or the corresponding SqlDbType value.

Use AddWithValue whenever you want to add a parameter by specifying its name and value.

关于sql - sqlcommand.parameters.add() 和 sqlcommand.parameters.addwithvalue() 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5527949/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com