QueryDef Equivalent

Zumo

New member
Joined
Mar 3, 2014
Messages
1
Programming Experience
Beginner
Hello,

I'm looking at the equivalent of QueryDef / QueryDefs under DAO (VB6) in VB.Net
I have already searched many sites but found no solution for it. :culpability:

About con.GetOleDbSchemaTable (...) I can not get the SQL text that describes the entire query.

Thanks for a tip

Zumo
 
Hi and welcome to the Forum,

If its the SQL code that you are trying to get to in each Query within an Access Database than have a play around with this snippet of code:-

Imports System.Data.OleDb
 
Public Class Form1
  Private myAccessConString As String = "YourAccessDataConnection"
 
  Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    Using accConn As New OleDbConnection(myAccessConString)
      accConn.Open()
      Using dtViewNames As DataTable = accConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "VIEW"})
        For Each currentRow As DataRow In dtViewNames.Rows
          Using dtViewDefinition As DataTable = accConn.GetOleDbSchemaTable(OleDbSchemaGuid.Views, New Object() {Nothing, Nothing, currentRow(2)})
            MsgBox(dtViewDefinition(0)(3))
          End Using
        Next
      End Using
    End Using
  End Sub
End Class


Hope that helps.

Cheers

Ian
 
Back
Top