I am having problems getting parameters to work within a VB.NET query written to AS/400. Any time I include a parameter in my query (ex. @MyParm) it doesn't work.
I get the following error:
SQL0206: Column @MyParm not in specified tables
Here's my code:
Dim da As New OleDbDataAdapter
Dim dt As New DataTable
da.SelectCommand = New OleDbCommand
da.SelectCommand.Connection = con
da.SelectCommand.CommandText = "SELECT * FROM MyTable WHERE Col1 = @MyParm"
.Add("@MyParm", OleDbType.Integer, 9)
.Item("@MyParm").Value = 5
I get the error here
It does work fine if I replace @MyParm with a literal of 5. What am I missing here?
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!