new OdbcParameter("

C

Christopher Weaver

I'm more than a little bit confused by the last parameter of one of the
overloads of this constructor. I'm pretty certain that I need to specify
that the parameter is an output and what the source column is, and so I'm
constrained to this overload. I just don't know what the last parameter is
for.

I'm creating the update SQL, shown below. I've included a reference to an
object in the tenth parameter, as required by the constructors parameter
list, but it seems to be redundant in light of the ninth parameter, which is
said to be the name of the source column. If anyone could shed some light
on this for me I would be very grateful.

Also, is there another way to go about this that would not involve using
this particular overload of the OdbcParameter constructor?

cmd.CommandText = "@UPDATE \"tblSubCategory\" SET \"SubCategory\" = ? "
+ "WHERE \"Category\" = ?; "
+ "UPDATE \"tblCategory\" SET \"Category\" =
? "
+ "WHERE \"Category\" = ?";
cmd.Parameters.Add(new System.Data.Odbc.OdbcParameter("SubCategory",
System.Data.Odbc.OdbcType.NVarChar, 50, "SubCategory"));
cmd.Parameters.Add(new System.Data.Odbc.OdbcParameter("Category",
System.Data.Odbc.OdbcType.NVarChar, 50, "Category"));
cmd.Parameters.Add(new System.Data.Odbc.OdbcParameter("NewCategory",
System.Data.Odbc.OdbcType.NVarChar, 50, "Category"));
cmd.Parameters.Add(new System.Data.Odbc.OdbcParameter("OldCategory",
System.Data.Odbc.OdbcType.NVarChar, 50, ParameterDirection.Output, false, 0,
0, "Category", DataRowVersion.Current,
dsCatSubCats.Tables["Categories"].Columns["Category"] ));
 
A

arunprakashb

As far as i see, the tenth parameter is the value of the Odbc Parameter
whereas the ninth parameter is the name of the parameter. Since the
category parameter is an output parameter in your case, you pass it as
null.

There is another way of doing this without using this constructor.

OdbcParameter category = new OdbcParameter();
category.Direction = ParameterDirection.Output;
.... this way you can set all properties that you want.

Not sure if this is what you want.

Regards,
Arun Prakash. B
 
C

Christopher Weaver

This may be exactly what I needed to know. I'm especially intrigued by the
option of setting the properties after the object is created. Can't believe
I didn't think of that!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top