Click here to Skip to main content
15,920,603 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionAdd Control during runtime Pin
bamnet6-Sep-06 16:11
bamnet6-Sep-06 16:11 
AnswerRe: Add Control during runtime Pin
Dave Sexton7-Sep-06 0:54
Dave Sexton7-Sep-06 0:54 
GeneralRe: Add Control during runtime Pin
bamnet7-Sep-06 4:11
bamnet7-Sep-06 4:11 
GeneralRe: Add Control during runtime Pin
Dave Kreskowiak7-Sep-06 5:13
mveDave Kreskowiak7-Sep-06 5:13 
GeneralRe: Add Control during runtime Pin
bamnet7-Sep-06 7:30
bamnet7-Sep-06 7:30 
QuestionRe: Add Control during runtime Pin
bamnet7-Sep-06 16:19
bamnet7-Sep-06 16:19 
AnswerRe: Add Control during runtime Pin
Dave Sexton7-Sep-06 22:07
Dave Sexton7-Sep-06 22:07 
QuestionHow do I return only the columns I'm interested in? Pin
Quecumber2566-Sep-06 10:21
Quecumber2566-Sep-06 10:21 
Hi everyone:
While digging down into the ADO.NET side of VB.NET I came across a nice little bit of code that allows me to return the schema of a database table.

Code snippet:
Private Sub Table_Schema(ByVal strTbl As String)
'Retrieving schema for columns from a single table
Dim cmd As OleDbCommand = New OleDbCommand(strTbl, objConnection)
cmd.CommandType = CommandType.TableDirect
Try
'Retrieve schema only
objConnection.Open()
'Dim reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.SchemaOnly)
Dim reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.KeyInfo)
'Get references to schema information
Dim SchemaTable As DataTable = reader.GetSchemaTable()
'Close and release the connection before processing results
reader.Close()
objConnection.Close()
'Display schema table column headers
Dim col As DataColumn
SchemaTableList.View = View.Details
SchemaTableList.Clear()
For Each col In SchemaTable.Columns
SchemaTableList.Columns.Add(col.ColumnName, 100, HorizontalAlignment.Left)
Next
'Display Schema
Dim row As DataRow
Dim ColCount As Integer = SchemaTable.Columns.Count
For Each row In SchemaTable.Rows
Dim OrderDetails(ColCount) As String
Dim ColIdx As Integer
For ColIdx = 0 To ColCount - 1
OrderDetails(ColIdx) = Convert.ToString(row(ColIdx))
Next
Dim NewItem As ListViewItem = New ListViewItem(OrderDetails)
SchemaTableList.Items.Add(NewItem)
Next
Catch OleDbExceptionErr As OleDbException
'Display the error
MessageBox.Show(OleDbExceptionErr.Message, "Access SQL")
End Try
End Sub

The problem I have is; I don't need all that schema information. All I'm interested in is the Name of the Column, the datatype of the column and is it a primary column(field) or not.

In VB6 you could determine what information you wanted returned to you. My question is: Is there such a method available in VB.NET/ADO.NET? If so, How do you set it up for use?

Quecumber256
Questionneed some help with printing in VB.net Pin
olekrh6-Sep-06 7:18
olekrh6-Sep-06 7:18 
AnswerRe: need some help with printing in VB.net Pin
Stephen McGuire6-Sep-06 8:49
Stephen McGuire6-Sep-06 8:49 
QuestionDelete Executable Pin
_mubashir6-Sep-06 5:23
_mubashir6-Sep-06 5:23 
AnswerRe: Delete Executable Pin
Dave Kreskowiak6-Sep-06 6:52
mveDave Kreskowiak6-Sep-06 6:52 
GeneralRe: Delete Executable Pin
Ray Cassick6-Sep-06 11:30
Ray Cassick6-Sep-06 11:30 
GeneralRe: Delete Executable Pin
Dave Kreskowiak7-Sep-06 3:46
mveDave Kreskowiak7-Sep-06 3:46 
QuestionConsole application with forms - how can I show forms and keep the console application running? Pin
EnglishRob6-Sep-06 4:55
EnglishRob6-Sep-06 4:55 
AnswerRe: Console application with forms - how can I show forms and keep the console application running? Pin
Dave Kreskowiak6-Sep-06 6:57
mveDave Kreskowiak6-Sep-06 6:57 
GeneralRe: Console application with forms - how can I show forms and keep the console application running? Pin
EnglishRob7-Sep-06 0:07
EnglishRob7-Sep-06 0:07 
GeneralRe: Console application with forms - how can I show forms and keep the console application running? Pin
Dave Kreskowiak7-Sep-06 3:40
mveDave Kreskowiak7-Sep-06 3:40 
QuestionInstallShield 11.5 and Crystal Reports Merge Modules Pin
Steven J Jowett6-Sep-06 4:18
Steven J Jowett6-Sep-06 4:18 
QuestionMaking components Pin
Magno R. Vasquez6-Sep-06 3:19
Magno R. Vasquez6-Sep-06 3:19 
AnswerRe: Making components Pin
Dave Sexton6-Sep-06 4:00
Dave Sexton6-Sep-06 4:00 
QuestionHow Get Cpu Name Pin
FriendlySoluations6-Sep-06 2:04
FriendlySoluations6-Sep-06 2:04 
AnswerRe: How Get Cpu Name Pin
Clanguage6-Sep-06 2:50
Clanguage6-Sep-06 2:50 
GeneralRe: How Get Cpu Name Pin
Colin Angus Mackay6-Sep-06 3:17
Colin Angus Mackay6-Sep-06 3:17 
GeneralRe: How Get Cpu Name Pin
Clanguage6-Sep-06 7:03
Clanguage6-Sep-06 7:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.