Using ADO.NET to retrieve the schema of a dynamic query.
Private Function GetQuerySchema(ByVal strconn As String, ByVal strSQL As String) As DataTable
Dim sconQuery As New SqlConnection
Dim scmdQuery As New SqlCommand
Dim srdrQuery As SqlDataReader = Nothing
Dim intRowsCount As Integer = 0
Dim dtSchema As New Data.DataTable
sconQuery.ConnectionString = strconn
scmdQuery.Connection = sconQuery
scmdQuery.CommandText = strSQL
srdrQuery = scmdQuery.ExecuteReader(Data.CommandBehavior.SchemaOnly)
dtSchema = srdrQuery.GetSchemaTable
Catch ex As Exception
Err.Raise(-1000, , "Error = '" & ex.Message & " ': sql = " & strSQL)
If Not IsNothing(srdrQuery) Then
If Not srdrQuery.IsClosed Then srdrQuery.Close()
About the Author
Joe Kunk is a Microsoft MVP in Visual Basic, three-time president of the Greater Lansing User Group for .NET, and developer for Dart Container Corporation of Mason, Michigan. He's been developing software for over 30 years and has worked in the education, government, financial and manufacturing industries. Kunk's co-authored the book "Professional DevExpress ASP.NET Controls" (Wrox Programmer to Programmer, 2009). He can be reached via email at [email protected].
User experience expert Debbie Levitt provided some saucy answers about an upcoming Visual Studio Live! presentation with an even saucier title: Fast Focus: WTF UX - UX Research and Design AMA.
Developers can now sign up for a private preview of enhanced chat capabilities coming to GitHub Copilot, the "AI pair programmer" that works in the Visual Studio 2022 IDE and in Visual Studio Code.
With advanced generative AI systems reshaping software development, Microsoft's Mads Kristensen detailed the many ways AI will improve coding in Visual Studio.
With Google recently releasing a generative AI-powered search bot called Bard to rival Microsoft's "new Bing" search experience, we put both to the test, feeding them identical questions about Visual Studio and .NET.
GPT-4, the advanced generative AI model from Microsoft partner OpenAI, is now powering the new GitHub Copilot X and the Azure OpenAI Service.
> More Webcasts