public static DataTable SqlDataTable(string sql, IDictionary<string, object> values)
{
using (SqlConnection conn = new SqlConnection(GetConnectionString))
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
conn.Open();
foreach (var item in values)
{
cmd.Parameters.AddWithvalue("@" + item.Key, item.Value); // error
}
.......
........
Error 4 'System.Data.SqlClient.SqlParameterCollection' does not contain a definition for 'AddWithvalue' and no extension method 'AddWithvalue' accepting a first argument of type 'System.Data.SqlClient.SqlParameterCollection' could be found (are you missing a using directive or an assembly reference?)
Why I get this error ?
C#
是case-sensitive
语言。您尝试调用的方法是AddWithValue
,大写V
而不是AddWithvalue
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.