This code sample shows the basic step of opening a VistaDB database.
The following code examples show how to perform common data operations using ADO.NET in a VistaDB-exclusive manner; Developers are encouraged to use the alternate approach that uses Database Factory objects since it will work for VistaDB and SQL Server without any code changes.
This code assumes that the appropriate VistaDB Provider has been referenced by your project and the following namespace has been imported:
VistaDB.Provider
This code sample shows the basic step of opening a VistaDB database.
Most database operations require creating a DbCommand object, configuring it for your operation, and associating it with a database connection to work with. This example shows creating the connection and command and associating them together.
In this example the command is being used to execute a simple TSQL insert. Since no data set is expected in return the ExecuteNonQuery() method is used to execute the command.
In this example the command is being used to execute a simple TSQL insert. It improves on the previous example by using a parameterized TSQL statement and ADO.NET Parameters to pass data. It is highly recommended that parameters always be used to pass data from your application to ADO.NET for reliability, consistency, and to ensure there is no possibility of a SQL Injection Attack against your code.
To retrieve multiple rows of data from a database ADO.NET uses a TableAdapter to fill a DataTable. The DataTable can have exactly one set of rows with a common schema.
Like Microsoft SQL Server, VistaDB supports Stored Procedures. In this example the stored procedure "CalcSalesTax" is being called with several parameters. To prevent SQL Injection attacks parameterized commands should be used to pass data to stored procedures instead of attempting to assemble the query as a string.