Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    Midwest
    Posts
    6

    Question Unanswered: how to retrieve a table field size on the fly in asp

    Ok,

    I have found the code to retrieve the contents and column names from a MySql database in asp. (see the code below) What I am wondering, is if there is a way for the script page to find the size of database field so I can make the maxlength of a textbox equal to this value? Thanks in advance.

    Set conn = Server.CreateObject("ADODB.Connection")
    conn.open= "driver={MySQL ODBC 3.51 Driver};server=localhost;uid=user;pwd=pwd;database =myDb;Option=16387;"
    mySql = "Select * From " & strTbl
    set rsTbl = conn.Execute(mySql)

    Response.Write "<table border=1>"
    For Each Field in rsTbl.Fields
    %>
    <tr><td><% =Field.Name %></td><td><input type="text" name="<% =Field.Name %>" size="40" <% 'maxlength value from database field would go here %> ></td></tr>
    <%
    Next
    Response.Write "</table><br>"

  2. #2
    Join Date
    Oct 2003
    Location
    Slovakia
    Posts
    482

    Re: how to retrieve a table field size on the fly in asp

    Originally posted by mb92010
    Ok,

    I have found the code to retrieve the contents and column names from a MySql database in asp. (see the code below) What I am wondering, is if there is a way for the script page to find the size of database field so I can make the maxlength of a textbox equal to this value? Thanks in advance.

    Set conn = Server.CreateObject("ADODB.Connection")
    conn.open= "driver={MySQL ODBC 3.51 Driver};server=localhost;uid=user;pwd=pwd;database =myDb;Option=16387;"
    mySql = "Select * From " & strTbl
    set rsTbl = conn.Execute(mySql)

    Response.Write "<table border=1>"
    For Each Field in rsTbl.Fields
    %>
    <tr><td><% =Field.Name %></td><td><input type="text" name="<% =Field.Name %>" size="40" <% 'maxlength value from database field would go here %> ></td></tr>
    <%
    Next
    Response.Write "</table><br>"
    I think this question belong to ASP section...

  3. #3
    Join Date
    Feb 2004
    Location
    Midwest
    Posts
    6
    A reply was given in the ASP section.

    <%= Field.DefinedSize %>

    This is not neccessasarily just an ASP question. Database knowledge has to be there too. Anyway, thanks for looking at the question. I may have to buy a MS SQL book also, I guess that the DefinedSize comes from MS SQL properties.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •