0
    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 ?

1 Answer 1

1

C# is a case-sensitive language.The method you are trying to call is AddWithValue with capital V not AddWithvalue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.