August 11, 2003

Calling web services from behind a proxy server

When you use a web service’s proxy class, the calls to the web service might fail if you’re behind a proxy server. To solve the problem, you set the Proxy property of a web service’s proxy class to an instance of WebProxy, that contains the HTTP proxy settings needed for

Discovering if the input OLEDB connection string points to a SQL Server DB

‘ 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(IsOleDbSqlConnString(“Provider=Microsoft.Jet.OLEDB.4.0;Data ‘ Source=D:MyDB.mdb;”)) ‘ => FalseFunction IsOleDbSqlConnString(ByVal connString As String) connString = connString.ToLower() Return (connString.IndexOf(“sqloledb”) > -1)End Function

Discovering if the input connection string is for the SQL Server managed provider

‘ Return a boolean indicating whether the input connection string is for the’ ADO.NET’s SQL Server managed provider’ Note: the function assumes the input string is a valid OLEDB or SQL Server’ connection string, and it just verifies it does not contain the “Provider” ‘ value” Examples:’ Debug.WriteLine(IsSqlProviderConnString’ (“server=(local);database=MyDB;uid=sa;pwd=;”)) ‘

Extracting the database’s name or path from the connection string

‘ Return the Database name if the input connection string points to a SQL ‘ Server DB, or the DB path if the connection string points to a Jet (Access) DB’ ‘ Examples:’ Debug.WriteLine(GetDatabaseName(“Provider=Microsoft.Jet.OLEDB.4.0;Data ‘ Source=D:MyDB.mdb;”)) ‘ => D:MyDB.mdb;’ Debug.WriteLine(GetDatabaseName(“Provider=SQLOLEDB.1;Data Source=.;User ‘ ID=sa;Password=;Initial Catalog=MyDB”)) ‘ => MyDB’ Debug.WriteLine(GetDatabaseName(“server=(local);database=MyDB;uid=sa;pwd=;”)’ ) ‘

Using aliases to quickly change the type of variables

It may happen that you have to define a lot of variable of some type, and you want the possibility to later change their type without manually change the declaration of all of them. You can’t use a simple Find & Replace, because you don’t want to change the type