Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
Search the Tips
Tip Bank > Web Development > ADO and ADO.NET

ADO and ADO.NET - Page 2

21-40 of 117     Previous     Next
Discovering if the input OLEDB connection string points to a SQL Server DB
by Marco Bellinaso
Return a boolean indicating whether the input connection string for the OLEDB managed provider points to a SQL Server DB Examples: Debug.WriteLine(IsOleDbSqlConnString("Provider=SQLOLEDB.1;Data Source=.;User ID=sa;Password=;Initial Catalog=MyDB")) ' => True Debug.WriteLine(IsOl
GetMdacVersion - Retrieve the installed MDAC version
by Marco Bellinaso
Retrieve the installed MDAC version Examples: Dim ver As Version = GetMdacVersion() print the full version MessageBox.Show(ver.ToString()) print the major and minor portions MessageBox.Show("Major: " & ver.Major & ", Minor: " & ver.Minor) check whether the current version is at least 2.7
SetCommandsTransaction - Assign a transaction to the DataAdapter's commands
by Marco Bellinaso
Assign the same transaction to the Update/Delete/Insert commands of all the OleDb/SqlAdapters passed in input Note: all the DataAdapters must be of the same type (OleDb or Sql) Note: requires Imports System.Data.OleDb and Imports System.Data.SqlClient Example: SetCommandsTransaction(tran, ...
ExecuteSqlScripts - Executing an array of script files
by Marco Bellinaso
Execute an array of sql script files with batch statements, by using the same SqlCommand object - connString is the connection string for the destination database Example: Dim connString As String = "server=(local);Persist Security Info=False;Integrated Security=SSPI;database=TestDB" Dim ...
GetDatabaseTables - Retrieving the table names of a database
by Marco Bellinaso
Returns the names of all the tables in the database identified by the input connection string Requires Imports System.Data.OleDb Example: Dim tables() As String = GetDatabaseTables("PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=d:\testdb.mdb") Dim table As String For Each table In tables
GetSqlServerDatabases - Retrieving the name of the installed SQL Server databases
by Marco Bellinaso
Returns an array with the installed SQL Server databases The first param must be a valid connection string to the 'master' database Requires Imports System.Data.SqlClient Example: Dim databases() As String = GetSqlServerDatabases( _ "server=(local); Database=master; user id=sa; ...
GetTableColumns - Retrieving the column names of a table in a database
by Marco Bellinaso
Returns the names of all the columns in the specified database table. The database is identified by the input connection string Requires Imports System.Data.OleDb Example: Dim columns() As String = GetTableColumns("PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=d:\testdb.mdb", "TestTable")
IsSqlServerDatabasePresent - Checking whether a SQL Server database is present
by Marco Bellinaso
Returns whether a SQL Server DB with the specified name is present The first param must be a valid connection string to the 'master' database Requires Imports System.Data.SqlClient Example: Debug.WriteLine(IsSqlServerDatabasePresent( _ "server=(local); Database=master; user id=sa; ...
ExecuteBatch - Executing a batch of OleDb commands
by Marco Bellinaso
Execute a batch of OleDb commands. Parameters: - The list of statements separated by ; chars. Use the ? char as a placeholder for a parameter. - The array of OleParameter objects that will replace the ? chars - an optional Boolean that specifies whether the transaction will be rolled back ...
BackupDatabase - Backing-up a SQL Server database
by Marco Bellinaso
Backup the specified database. Note: requires Imports System.Data.SqlClient Example: Dim connString As String = "server=(local); user id=sa; password=; Database=master;" Try BackupDatabase(connString, "MyTestDB", "D:\MyTestDbBackup.bak") Catch ex As Exception MessageBox.Show(ex.Message)
Calculated columns that refer to relationships
by Marco Bellinaso
The DataSet is a container of multiple DataTables, and it allows to create parent-child relationships between two tables, as shown below: ' create a relationship between the Categories and the Products tables, against the CatID column ds.Relations.Add(New DataRelation("CatProducts", ...
CreateConnString - Using the OLEDB dialog to create an OLEDB connection string
by Marco Bellinaso
This function opens the OLEDB dialog to create an OLEDB connection string, and return the selection It requires the OLEDB Service Component 1.0 Type Library to work
CreateDatabase - Creating a SQL Server database
by Marco Bellinaso
Create a SQL Server database with the specified name. If the second parameter is True and a DB with the same name is already present, it is dropped before the new DB is created. Note: requires Imports System.Data.SqlClient Example: Dim connString As String = "server=(local); user id=sa; ...
RestoreDatabase - Restoring a SQL Server database
by Marco Bellinaso
Restore the specified database. Note: requires Imports System.Data.SqlClient Example: Dim connString As String = "server=(local); user id=sa; password=; Database=master;" Try RestoreDatabase(connString, "MyTestDB", "D:\MyTestDbBackup.bak") Catch ex As Exception MessageBox.Show(ex.
The DataTable's Compute method
by Marco Bellinaso
The DataTable class has a method, Compute, that executes SQL-like functions on the rows locally stored in the DataTable. It supports functions such as COUNT, SUM, MIN, MAX, AVG and others. Here's an example to calculate the average salary for the employees stored in the tableEmployees ...
DbObject - A base data class for common DB operations
by Kevin Hoffman
A base data class that makes it much easier for derived classes to run a stored procedure to retrieve data or execute a SQL command. (See usage examples at the bottom)
CheckOLEDBProvider - Check whether an OLEDB provider is registered correctly
by Marco Bellinaso
Check if the specified OLEDB Provider is installed and registered correctly Example: check the Jet 4.0 OLEDB Provider MsgBox "The specified OLEDB provider " & _ IIf(CheckOLEDBProvider("Microsoft.Jet.OLEDB.4.0"), "does", "does not") & " exist" NOTES: Requires CheckRegistryKey and ...
GetOleDbType - Retrieving the OleDbType for the specified system type
by Marco Bellinaso
Return the OleDbType that represents the specified system type This is particularly useful when you have a DataTable and want to create a OleDbParameter for onw of its columns, but don't know its type. DataColumnName.DataType returns a Type, and you can convert it to OleDbType by passing it to ...
Include schema information in a DataSet's DiffGram
by Dino Esposito
In the .NET Framework, the DataSet's WriteXml method when used to create a DiffGram does not provide the capability to include schema information along with the data. This is more of a design choice than an objective difficulty, though. When you return a DataSet object from a Web service method ...
Persist ADO.NET extended properties
by Dino Esposito
Many ADO.NET classes, including DataSet, DataTable, and DataColumn, use the ExtendedProperties property to enable users to add custom information. Think of the ExtendedProperties property as a kind of generic cargo variable similar to the Tag property of many ActiveX controls. You populate it ...
21-40 of 117     Previous     Next
Sitemap