How to get the Field Size of Access Table?

  • Thread starter Thread starter Chrysan
  • Start date Start date
C

Chrysan

I am using Microsoft Access as my application's database.

How do I get the Field Size of the field in Access Table
from Visual Basic? Because I am going the set the
TextBox.Maxlength property according the the Field Size of
the field in Access Table.

Thanks. ^_^
 
here is something which is working with sql server
modify it for Access.change the connection etc.this code will give u all
the properties of the table.

<%@ Page Language="VB" debug=true%>
<%@ Import namespace="System.Data"%>
<%@ Import namespace="System.Data.SqlClient"%>
<script language="VB" runat=server>
sub page_load

dim con as new
SqlConnection("Server=rajesh;database=test;uid=sa;pwd=sa")
con.Open()
dim cmd1 as new SqlCommand("select * from student_mst",con)
dim dr as SqlDataReader
dr=cmd1.ExecuteReader(CommandBehavior.SchemaOnly or
CommandBehavior.KeyInfo)
dim dt as new DataTable
dt=dr.GetSchemaTable()
dim myrow as Datarow
for each myRow in dt.Rows
dim mycol as datacolumn
for each myCol in dt.Columns
Response.write(myCol.ColumnName.tostring() & " = " &
myRow(myCol).tostring())
Response.write("<br>")
next
next
end sub
</script>
hope it helps
rajesh
 
Back
Top