.net, SQLDataTableAdapters
I have a sql query method using SQL data table adapters in a .xsd file and should be able to dynamically change the connection string to that method in the code behind. I cannot figure out how to access the properties of the methods from the code.
the IsValidDock () method, just checks the database for a specific dock number and returns a bool.
Basically I am creating a request in my code behind
Dim SQLCommands as new SQLDataTableAdapters.SQLCommands ()
I thought I could go to method properties
SQLCommands.IsValidDock (). some properties. This doesn't work, any ideas?
a source to share
Better question, perhaps, however, why do you need to change this connection on the fly? Could you just change the definition and call it a day? Do you have multiple database servers that you work with? Connection strings are saved in the configuration for the project, so if this is a situation where you need a different connection in test and production environments, you can simply have two configuration files.
Assuming this is not a solution, read ...
If I remember correctly, the SqlDataTableAdapter objects that were squished by the XSD parser in Visual Studio are subclasses of the SqlDataAdapter, right (you can find out in Visual Studio by right-clicking the link for one and choosing Go to Definition)? so, you can simply instantiate the generated class (it must have a generated .cs or .vb file in it) and pass the customized SqlConnection object to it.
There is no interface for changing the data adapter connection after it has been created. The adapter opens the connection when you do whatever it needs to do (call Fill (), Insert (), etc.) and only close it when the SqlDataAdapter is placed.
a source to share