SQL server database has a syscolumns table which contains columns of each table in the database. You can get the column name by using the following query.
SELECT [Name] FROM syscolumns
WHERE id=OBJECT_ID(N'dbo.tblProducts')
ORDER BY colid
To call it from a VB.NET application, you can use SqlDataReader the same way you do it on a ordinary table.
cmd.CommandText = "SELECT [Name] FROM syscolumns WHERE id=OBJECT_ID(N'dbo.tblProducts') ORDER BY colid"
Dim lrd As SqlDataReader = cmd.ExecuteReader()
cboProducts.Items.Clear()
While lrd.Read()
cboProducts.Items.Add(lrd("[Name]").ToString())
End While
To stay up-to-date on Technology news, subscribe now.
0 comments:
Post a Comment