>< input style="HEIGHT: 20px; LEFT: 110px; POSITION: absolute; > TOP: 5px; WIDTH: 100px; FONT-SIZE: 9pt;" > id=txtQCEContact > name=txtQCEContact > value=" <%= oRS(QCEContact) " > ReadOnly > maxlength=" <%=oRS(QCEContact).DefineSize “> >>
public static DataTable FieldLength() { string selectStatement = "SELECT * " + "FROM UserInfo WHERE 1 = 2 "; SqlCommand selectCommand = new SqlCommand(selectStatement,ScrapConnection.GetConnection()); SqlDataAdapter userDataAdapter = new SqlDataAdapter(selectCommand); DataSet userDataSet = new DataSet(); userDataAdapter.FillSchema(userDataSet, SchemaType.Source, "UserInfo"); ScrapConnection.GetConnection().Close(); return userDataSet.Tables["UserInfo"]; }In the forms Load
string FirstName; FirstName = UsersDB.FieldLength().Columns["FirstName"].MaxLength.ToString(); txtFirstName.MaxLength = Convert.ToInt32(FirstName); string LastName; LastName = UsersDB.FieldLength().Columns["LastName"].MaxLength.ToString(); txtLastName.MaxLength = Convert.ToInt32(LastName);I am sure that there are other solutions but this works for now.