How to get the Field Size of Access Table?

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. ^_^
 
R

Rajesh Tiwari

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top