If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ASP page that reads a field length from MySql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-04, 12:01
mb92010 mb92010 is offline
Registered User
 
Join Date: Feb 2004
Location: Midwest
Posts: 6
ASP page that reads a field length from MySql

I've searched as much as I can to find how to retrieve the field length from a field in a MySql database.

I want to build a page that will pull information from a database table. I have found the code to display the field names, but want to use the field length of the original mySql field to determine the maxlength of the textbox for my add page. If the answer has already been posted, I apologize. Thanks in advance!

The page would look something like this:

ID: [ ]
Name: [ ]
Description [ ]

I used the [] to represent the size of the textboxes.
Reply With Quote
  #2 (permalink)  
Old 02-07-04, 13:32
mb92010 mb92010 is offline
Registered User
 
Join Date: Feb 2004
Location: Midwest
Posts: 6
Code included:

Sorry, didn't post the code before, but here it is.

where the comment is below is where the field size would come in very handy:

Set conn = Server.CreateObject("ADODB.Connection")
conn.open= "driver={MySQL ODBC 3.51 Driver};server=localhost;uid=user;pwd=password;dat abase=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="<% 'Code to retrieve field size would go here%>" ></td></tr>
<%
Next
Response.Write "</table><br>"
Reply With Quote
  #3 (permalink)  
Old 02-08-04, 00:23
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
Len(string) returns the number of characters in a string.
Reply With Quote
  #4 (permalink)  
Old 02-08-04, 20:12
mb92010 mb92010 is offline
Registered User
 
Join Date: Feb 2004
Location: Midwest
Posts: 6
The Len() statement did not retrieve the value from the database table properties. When viewing the table with MySql Control Center for example, a field may be defined as text with a maximum length of 40. I would like to know how my ASP page can retrieve this information from the MySql database properties. Maybe this is not possible, I don't know. I do thank you for your response.
Reply With Quote
  #5 (permalink)  
Old 02-09-04, 22:13
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
<%= Field.DefinedSize %> displays the defined size of the Field object. It works with MS SQL server 2000.
Reply With Quote
  #6 (permalink)  
Old 02-11-04, 08:21
mb92010 mb92010 is offline
Registered User
 
Join Date: Feb 2004
Location: Midwest
Posts: 6
Smile

Thank you SO much, that is it!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On