Reputation: 469
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 ?
Upvotes: 0
Views: 2513
Reputation: 101731
C#
is a case-sensitive
language.The method you are trying to call is AddWithValue
with capital V
not AddWithvalue
.
Upvotes: 1