I have a vb.net desktop program, which uses ODBC to connect to database. I need to use GetSchema() to get the user's table from database.
I find that if I use OleDbConnection.GetSchema(), it works fine, OdbcConnection.GetSchema("Tables") works fine too, only OdbcConnection.GetSchema("Tables", FilterValues) doesn't work, an error is occurred, it say:
System.ArgumentException : In addition to the required architectural (" tables ") support, there are more restrictions.
My program need to support OdbcConnection, my develop environment is win7 chinese + visual studio 2019, the program's target framework is .net 2.0. I have ever try to change target framework to 4.6, 4.72 etc, they don't work.
Anyone know how to solve the problem? Thanks.
The codes are as follows:
Private Sub TryGetSchema()
Dim OleDbConn As New OleDbConnection
Dim OdbcConn As New OdbcConnection
Dim FilterValues As Array
Dim mySchema As New DataTable
FilterValues = {Nothing, Nothing, Nothing, "TABLE"}
'OleDbConnection works fine:
OleDbConn.ConnectionString = "Provider=SQLNCLI10;Server=(local);Database=test;Uid=sa;Pwd=123456;"
OleDbConn.Open()
mySchema = OleDbConn.GetSchema("Tables")
mySchema = OleDbConn.GetSchema("Tables", FilterValues)
OleDbConn.Close()
'OdbcConnection
OdbcConn.ConnectionString = "Driver={SQL Server Native Client 10.0};Server=(local);Database=test;Uid=sa;Pwd=123456;"
OdbcConn.Open()
'GetSchema("Tables") works fine too:
mySchema = OdbcConn.GetSchema("Tables")
'GetSchema("Tables", FilterValues) doesn't work, an error is occurred, it say:
'System.ArgumentException : In addition to the required architectural (" tables ") support, there are more restrictions.
mySchema = OdbcConn.GetSchema("Tables", FilterValues)
OdbcConn.Close()
End Sub
The error screen is as follows:
Hi XingyuZhao-MSFT,
The project is private and big, it's not convenient to share, the whole code related to GetSchema() had been posted in TryGetSchema() subroutine, You create a new project, then copy and paste the code to the project to try If it doesn't work yet, I will created a new project for your. Thanks.
Hi @bob guo ,
We do not collect any information. Please be careful not to show any personal information on the forum.