Last post Jul 11, 2007 05:02 PM by ndinakar
Jul 11, 2007 03:08 PM|girishnehte|LINK
I am working on a web application and using Sql Server 2005 as a Databasew. I want to define a variable with the datatype as defined in the database. Let me give an example.
In my web say there is a field "First Name" and for that I had created a TextBox "txtFirstName" in code behind to get this value I have defined a variable
Now this variable has to be stored into the table "Person" into the column "FirstName" which is of type "nvarchar" and having length "20" So I want to get this length programatically so that I can assign this number (20) to the maxlength property of the textbox
"txtFirstName" so that in future if the legth of the database column changes it should no be needed to change in code also.
Caqn it be done? If yes please let me know.
Thanks & Regards
Jul 11, 2007 03:17 PM|ca8msm|LINK
You can use the sp_Help stored procedure to get information about a particular object e.g.
Website Design Darlington - http://lessthandot.com -
Jul 11, 2007 05:02 PM|ndinakar|LINK
do you mean you want to get the lengths for each parameter defined in your app code, from the DB? That will be a LOT of DB calls just for parameter declaration and looks like a bad design IMHO. Get the requirements right and factor in any growth. Normally
you dont have to change column lengths unless your INT value reaches for an INT column or one of your numeric columns reaches its limits.