![VB.NET源码-156个实用实例哦……](http://www.zhzx123.com/VB.NET_03.gif)
数据存取问题
请问如何将数据库中表里的字段名取出来?
比如说学生信息表中的学号 姓名 成绩等等 这样的名字怎样取出来?
能否写一下代码 谢谢各位 请指教
__________________________________________________________________________
select name
from syscolumns where id=object_id( ''tablename '')
__________________________________________________________________________
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim da As New SqlDataAdapter( "SELECT * FROM 表名 ", "您的连接词 ")
Dim ds As New DataSet
da.Fill(ds)
For i As Int32 = 0 To ds.Tables(0).Columns.Count - 1
MsgBox(ds.Tables(0).Columns(i).Caption)
Next
End Sub
End Class
__________________________________________________________________________
列出表里的所有的字段:
select name from syscolumns where id=object_id( ''TableName '')
顶ls的ls。
__________________________________________________________________________