gpt4 book ai didi

c# - SqlParameter.Add 和 AddWithValue 之间的区别

转载 作者:行者123 更新时间:2023-12-02 01:14:04 45 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Difference between Parameters.Add and Parameters.AddWithValue

从MSDN代码看,这两者有什么区别:

    SqlCommand command = new SqlCommand(commandText, connection);

//#1
command.Parameters.Add("@ID", SqlDbType.Int);
command.Parameters["@ID"].Value = customerID;

//#2
command.Parameters.AddWithValue("@demographics", demoXml);

做第一个以确保我正确地转换参数是否更好?我正在努力使我的代码更安全。

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