Error msg: No mapping exists from object type System.Data.SqlClient.SqlParameter to a known managed provider native type.

        Dim pID As New SqlParameter(“@ID”, SqlDbType.Int)

        pID.Value = TextBoxParentID.Text

        cmd.Parameters.AddWithValue(“@ID”, pID)

I changed it to:

        Dim pID As New SqlParameter(“@ID”, SqlDbType.Int)

        pID.Value = TextBoxParentID.Text

        cmd.Parameters.Add(pID)

and it works

also this works:

        Dim pID As New SqlParameter(“@ID”, SqlDbType.Int)

        cmd.Parameters.Add(“@ID”, SqlDbType.Int)

        cmd.Parameters(“@ID”).Value = pID.Value

Change AddWithValue to Add

Cos you have a problem in type conversion and Add will take care of it.

After that I figured out what exactly was the error reason …

I was applying it wrongly:

        ID.Value = TextBoxParentID.Text

        cmd.Parameters.AddWithValue(“@parentID”, ID)

And the correct one is without ID.Value = TextBoxParentID.Text

You have to put the value in AddWithValue:

        cmd.Parameters.AddWithValue(“@parentID”, TextBoxParentID.Text)

Ahmed.

Advertisements

About Ahmed

Software craftsman, programmer, developer, system/business analyst, DBA and PM.
This entry was posted in Databases, Programming, SQL-Server, VB.NET and tagged , , , , , . Bookmark the permalink.

3 Responses to Error msg: No mapping exists from object type System.Data.SqlClient.SqlParameter to a known managed provider native type.

  1. Good post. I learn something totally new and challenging
    on sites I stumbleupon every day. It’s always helpful to read through articles from other writers and use a little something from their websites.

  2. Me says:

    Thanks. 🙂

  3. Responses to Error msg: No mapping exists from object type System.Data.SqlClient.SqlParameter to a known managed provider native type. can someone help me with this error msg?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s