TableAdapters and SQL

Hello everyone,

I had a question with regard to the new VS 2005 TableAdapters. They allow you to build "canned" SQL Queries and remane them FillBy1 FillBy2 etc. I also see that you can pass in parameters. You can push a button to run the query or call the Fillby routine in code. We need to do things differently. I want to pass a complete Query including the WHERE, which is built at runtime, to the TableAdapter and have it run it. We generate a complete SQL query using a search engine. I think we want to be able to get to the CommandText property of the TableAdapter and put in our SQL.


I have attempt some work on a solution for this but still do not know exactly how to finish it. I built a partial class which does expose the private property .CommandText.


When I run the routine: Call Me.BioTableAdapter.MyCode()

I get a runtime error which says: "Object Reference Not set to an Instance of an Object"


I am also not sure how to call the the SQL to fill the dataset once I have set CommandText.


Namespace BioProcDBDataSetTableAdapters

Partial Public Class bioTableAdapter

Public Sub MyCode()

Me.Adapter.SelectCommand.CommandType = CommandType.Text

Me.Adapter.SelectCommand.CommandText = "SELECT * From Bio"


End Sub

End Class


End Namespace


Any Help would be greatly appreciated. This is a critical question for us in our porting our Visual Basic 6 applications to VB.NET 2005.


Thanks so much

Fritz Klein



Answer this question

TableAdapters and SQL

  • TableAdapters and SQL