Use variable in Parameters

Asked

Viewed 45 times

1

I am trying to run the line below, but need to use variables. The line is as follows:

CM.Parameters.Add("desnome", System.Data.SqlDbType.VarChar).Value = USU.xdes_nome;

I need the following: desnome by variable Varchar by variable USU.xdes_nome by variable

Someone has a tip on how I can do it?

  • post the context where that code is, and I don’t understand "desnome" por variavel Varchar por variavel USU.xdes_nome por variavel

  • I think you misunderstood the use of Parameters.Add, you don’t have to pass the type, only the value.

1 answer

0

Your question is totally vague, but try the following:

    CM.Parameters.Add("@desnome", SqlDbType.Int);
    CM.Parameters["@desnome"].Value = USU.xdes_nome;

for the above example to work, you need to check the "Usu.xdes_name", if you are referring to a variable being called a class, it is correct, if not, modify the name.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.