SqlParameter SqlDBType.text size

M

Michael

What is the correct way to address the size of a SqlDBType.text field in a
SqlParameter

The Data Adapter configuration wizard does this
cmdUpdate.Parameters.Add("@myvar", SqlDbType.Varchar, 2147483647)

Is that right (I'm assuming so), but could I also do this? (using
SqlDbType.Text)

cmdUpdate.Parameters.Add("@myvar", SqlDbType.Text, 2147483647)
or even this, as the size is defined in Sql server

cmdUpdate.Parameters.Add("@other_accident_cause", SqlDbType.Text, 16)

Little confused here.. :)

--Michael
 
M

Miha Markic

Hi Michael,

In SqlServer size is refering to a "pointer" (thus it always 16) while in
ado.net size refers to the possible text size.
So cmdUpdate.Parameters.Add("@myvar", SqlDbType.Text, 2147483647) would be
right.
 

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