473,657 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Retrieve MaxLength of a Column?

Mel
Anyone know how I would retrieve the MaxLength property of a column in
my Access Database table? I know how to retrieve table data, for
example the "Quote #" field in my example code below, but I have never
attempted to access a property of a field.

'Beginning of my Code Example
Dim strConn As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=c:\suppo rt\webbmq.mdb;"
Dim strSel As String = "SELECT * FROM [Quotes] "
Dim conWebOrdNum As New System.Data.Ole Db.OleDbConnect ion(strConn)
Dim Rec As System.Data.Ole Db.OleDbDataRea der
Dim cmdRead As New System.Data.Ole Db.OleDbCommand (strSel,
conWebOrdNum)
conWebOrdNum.Op en()
Rec = cmdRead.Execute Reader()
Rec.Read()
Session("OrdNum ") = Rec("Quote #")
Rec.Close()
'End of my Code Example

Jun 14 '07 #1
1 1919
Mel
On Jun 14, 9:01 am, Mel <MLights...@gma il.comwrote:
Anyone know how I would retrieve the MaxLength property of a column in
my Access Database table? I know how to retrieve table data, for
example the "Quote #" field in my example code below, but I have never
attempted to access a property of a field.

'Beginning of my Code Example
Dim strConn As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=c:\suppo rt\webbmq.mdb;"
Dim strSel As String = "SELECT * FROM [Quotes] "
Dim conWebOrdNum As New System.Data.Ole Db.OleDbConnect ion(strConn)
Dim Rec As System.Data.Ole Db.OleDbDataRea der
Dim cmdRead As New System.Data.Ole Db.OleDbCommand (strSel,
conWebOrdNum)
conWebOrdNum.Op en()
Rec = cmdRead.Execute Reader()
Rec.Read()
Session("OrdNum ") = Rec("Quote #")
Rec.Close()
'End of my Code Example
Nevermind, I figured it out. Here is the code I ended up with.

'Beginning of my Code Example
Dim strConn As String = "Provider=Micro soft.JET.OLEDB. 4.0;Data Source
=" & "c:\support\web bmq.mdb"
Dim strRecQuotes As String = "SELECT * FROM [Quotes];"
Dim conQuotes As New System.Data.Ole Db.OleDbConnect ion(strConn)
Dim recQuotes As System.Data.Ole Db.OleDbDataRea der
Dim comQuotes As New System.Data.Ole Db.OleDbCommand (strRecQuotes,
conQuotes)
Dim dt As System.Data.Dat aTable

conQuotes.Open( )
recQuotes = comQuotes.Execu teReader()
recQuotes.Read( )

dt = recQuotes.GetSc hemaTable()

'SET THE TEXT BOX MAXLENGTH PROPERTIES TO THE COLUMN LENGTHS DEFINED
IN THE DATABASE
For i = 0 To dt.Rows.Count - 1
If UCase(Trim(dt.R ows(i)("ColumnN ame"))) = "CUSTOMER" Then
txtCustomer.Max Length = dt.Rows(i)("Col umnSize")
ElseIf UCase(Trim(dt.R ows(i)("ColumnN ame"))) = "PROJECT NAME"
Then
txtProjName.Max Length = dt.Rows(i)("Col umnSize")
ElseIf UCase(Trim(dt.R ows(i)("ColumnN ame"))) = "SHIP TO ADDRESS
1" Then
txtProjAddr1.Ma xLength = dt.Rows(i)("Col umnSize")
ElseIf UCase(Trim(dt.R ows(i)("ColumnN ame"))) = "SHIP TO ADDRESS
2" Then
txtProjAddr2.Ma xLength = dt.Rows(i)("Col umnSize")
ElseIf UCase(Trim(dt.R ows(i)("ColumnN ame"))) = "SHIP TO CITY"
Then
txtProjCity.Max Length = dt.Rows(i)("Col umnSize")
ElseIf UCase(Trim(dt.R ows(i)("ColumnN ame"))) = "SHIP TO ZIPCODE"
Then
txtZip.MaxLengt h = dt.Rows(i)("Col umnSize")
ElseIf UCase(Trim(dt.R ows(i)("ColumnN ame"))) = "CUSCONTACT " Then
txtCusContact.M axLength = dt.Rows(i)("Col umnSize")
ElseIf UCase(Trim(dt.R ows(i)("ColumnN ame"))) = "CUSPHONE" Then
txtCusPhone.Max Length = dt.Rows(i)("Col umnSize")
End If
Next
recQuotes.Close ()

If Not comQuotes Is Nothing Then
comQuotes.Dispo se()
End If
If Not recQuotes Is Nothing Then
recQuotes.Close ()
End If
'End of my Code Example

Jun 14 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
7444
by: Edward Mitchell | last post by:
I have a database with text string fields defined by varchar(nnn). When I request from the user the text from a textbox, I'd like to set the maximum number of characters in the textbox to the "nnn" that was used in the varchar(...) statement in the field definition. i.e. Field1 varchar(25) NOT NULL and in the .aspx file: <asp.textbox id=Field1 runat="server" />
2
1400
by: sql | last post by:
Hi all, I would like to set MaxLength property of asp.net controls on my page based on their corresponding field length in Sql Server table. I know I can get the TableSchema along with the record if I read the data into a DataSet. But I don't want to store data in a DataSet because I am going to work on only one record. So I don't want the overhead that comes with using a DataSet. I will probably use a custom entity object and fill it...
7
2609
by: ray | last post by:
My xsd has the following element: <xs:element name="Company" minOccurs="0"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="1" /> <xs:maxLength value="5" /> </xs:restriction> </xs:simpleType> </xs:element>
1
2670
by: Anthony | last post by:
I am defining the datagridtable style for a grid .... Dim coursekeycol As New DataGridTextBoxColumn coursekeycol.MappingName = COURSEKEYCOLNAME coursekeycol.HeaderText = "" coursekeycol.Width = COURSEKEYCOLWIDTH .... I am wondering, how to I set the cells so that the user
3
2000
by: lintolawrance | last post by:
sir, i am starting working with php.i done some programs.but now i have one problem.i do a program like to retrieve the name and email from a phpfile to another.but i can't get. this is the code "form.php" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html;...
5
25552
by: Ken | last post by:
I'm trying to run a loop to capture column property information from a table in my datasource. Can anybody see where this is going wrong? Dim tbl As New DataTable Dim col As DataColumn Dim x As Integer Dim colName(99) As String Dim colType(99) As String cn.Open() tbl = cn.GetSchema("Orders") 'Orders is a table in the
9
4781
by: Mel | last post by:
I have 10 columns total. 3 of them are invisible. The rest are read- only BoundFields, 3 of which are editable fields using TemplateFields. Upon editing, I want to validate what the user enters against one of those invisible columns. How do I accomplish this? The code below that I attempted just returns an empty string when I try to retrieve the invisible column data: gvParts.Rows(e.RowIndex).Cells(8).Text
14
6192
by: zionlion | last post by:
I want to only retrieve the values of one column in mysql and use these values to plot a graph. I know how to echo these values. However, I am unable to write them seperately. Let's say I have a table called cars. It has a column for car vin and a column for brand and a column for price. I just want to retrieve the column for the price and use these numbers to plot a bar graph. So the X-axis shows bar 1, 2, 3 ... and the bar length shows the...
9
5552
by: gavy7210 | last post by:
hello friends i am new to struts. i want to add the user information in the database and then display it back to him. i am using struts 1.2,Eclipse Platform Version: 3.4.2,mySql 5.0.1,jdk 1.5.. i have created a form bean to get the data from the user. then in my action class i m trying to get a database connection and adding the values of the user. and i also wanna show them back to him. its a dummy project for my learning(to get...
0
8411
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7351
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.