Friday, July 4, 2008

DBTyP.NET 2008 Release 3 Available

BYPsoft announced the availability of DBTyP.NET 2008 Release 3, the newest version of the cross-database comparison tool that compares SQL Server, MySQL and Oracle databases (schema and data). DBTyP.NET 2008 Release 3 is available for download from http://www.bypsoft.com.

With its rich support for schema and data cross-database comparison, DBTyP.NET takes the mystery out of databases, making their comparison practical and easy for programmers and database administrators everywhere. Over and above its powerful comparison capabilities till now, BYPsoft added to the DBTyP.NET 2008 support for schema comparisons for Oracle databases. Full cross database comparison family includes now support for SQL Server, MySQL and Oracle databases in the latest release of DBTyP.NET 2008 for a fraction of the cost of single-database solution.

Since the DBTyP.NET is under constant development, user interface has been redesigned and rich visual interface and easy-to-use features of DBTyP.NET 2008 allow developers and DBAs to identify and deploy changes quickly on all supported databases and enhance productivity and maximize results. Features like colorfull differences, different objects icons, visual column description, in place colorfull script differences, multiple views and more all save time and ensure accuracy.

In addition to all the new features listed above, in the latest release of DBTyP.NET 2008 BYPsoft includes also the following:

  • SQL Server 2008 Ready
  • Support for SQL Server ROWGUIDCOL
  • Filtered out system objects on SQL Server databases.
  • Support SQLServer user defined types.
  • Support MySQL ENUM and SET data types.

We know that constant development is the key to progress, therefore we already started working on all new cool features. Stay with us.

Monday, May 12, 2008

List All Functions and Stored Procedures definitions in Oracle schema

A long time I have not published anything. BYPsoft preparing new version of DBTyP.NET with full support for a Oracle schema comparison and therefore didn't had any free time left for this blog.
A very interesting topic came to me out of this experience.
Have you ever tried to get a list of all stored procedures and functions in Oracle schema? Preaty easy,
SELECT * FROM USER_PROCEDURES;
You figured out that it is quite different comparing to SQL Server and MySQL where with the single query
SELECT * FROM INFORMATION_SCHEMA.ROUTINES;
you get a body definition as well.
To achieve this on Oracle is not so simply. First, to get user sources you should query USER_SOURCE view where each function or stored procedure line is stored in one row.
To get a full body, you have to use a powerful hierarchical query clause
SYS_CONNECT_BY_PATH.
Here is a query which returns you list of all stored procedures and functions in Oracle schema together with their bodies defined in one column:


SELECT routine_name, y.TYPE, TRANSLATE(LTRIM(x.text1, '/'), '/', ' ') routine_definition
FROM (SELECT name routine_name, LEVEL lvl, sys_connect_by_path(text, '/') text1
FROM USER_SOURCE
CONNECT BY LINE - 1 = PRIOR LINE AND name = PRIOR name) x,
(SELECT name, TYPE, MAX(line) AS maxline
FROM USER_SOURCE
GROUP BY name, TYPE) y
WHERE x.routine_name = y.name AND x.lvl = y.maxline
ORDER BY TYPE, routine_name

Compare database schema and data fast and easy with DBTYP.NET Studio

Saturday, March 1, 2008

MySqlDateTime and .NET

In version 2008 our cross database comparison tool DBTyP.NET will support cross data comparison between SQL Server and MySQL DateTime values (date, datetime, smalldatetime). Actually, this is a common problem, between MySql.Data.Types.MySqlDateTime and System.DateTime types in .NET. It is very possible that if you tries to update MySqlDateTime column with DateTime variable you will get SystemArgumentException saying that could not store value ... into ... Expected type is MySqlDateTime. It is possible to format value as "yyyy-MM-dd HH:mm:ss" but in our case we don't want to iterate through whole DataSet and make this formatting.
Very elegant solution is to change a DataColumn type from MySqlDateTime to System.DateTime as

myMySqlDateTimeColum.DataType = typeof(System.DateTime);

After that you should not worry about formatting.

Friday, February 29, 2008

How to check if class has been used in Web or Windows application

After a while, I decided to participate in a newsgroups tonight and found an interesting question. "Is there a programmatic way for the class lib to determine what kind of app is running - web or windows". The worst, guy requested official response from Microsoft support and didn't get an answer. After 3 days his question wasn't answered, he re-posted it. So, is there are something wrong? Looks like not.
The simple answer from my side was, to implement following function somewhere in his shared assembly:
public bool IsWebApp(){
return (HttpContext.Current != null);
}

So, if there is Current HttpContext than function has been called from ASP.NET application and if there is not such an object, function is called from Windows Forms application.
Simple enough.

Tuesday, February 26, 2008

Handling Miliseconds in .NET and SQL Server

Have you taken a look at number of such a questions in online community? It looks like that a lot of .NET developers have a problems reading and updating milliseconds value from SQL Server databases. So what is a real problem here?
Let's take a look at common scenario. Developers read data from a table which has Datetime column ColDateTime. Let's say they are storing values in some DataTable table1. Suddenly, if you want just to print a Value of that field, with

table1.Rows[0].Cells["ColDateTime"].Value.ToString()

you will get value like '2008/02/26 2:26:53 PM'. But you value in database is actually '2008/02/26 14:26:53.3480'. So milliseconds are missing. The only way to get them is to convert value from database in DateTime variable and then print out that variable:

DateTime dtDbValue = System.Covert.ToDateTime(table1.Rows[0].Cells["ColDateTime"]);
dtDbValue.ToString();


Now, you have a real value: '2008/02/26 14:26:53.3480'

Connected to this is also reverse process, where people lose milliseconds during update. Take a look at following statements:

DateTame dtValue = DateTime.Now;

string sql = "update table1 set ColDateTime = '" + dtValue.ToString() + "'";

-- create DataCommand, assign CommandText and execute.

You will see that your column has been updated with the wrong value. Again milliseconds cut.

People try very often to format ToString method call to looks like:
string sql = "update table1 set ColDateTime = '" + dtValue.ToString("yyyy/MM/dd hh:mm:ss.ffff") + "'";

but this cause an exception on SQL Server side saying that varchar value can not be converted to Datetime type. Strange, and maybe lack of documentation, but the solution is to format your DateTime value with different format - using 3 f and not 4:

string sql = "update table1 set ColDateTime = '" + dtValue.ToString("yyyy/MM/dd hh:mm:ss.fff") + "'";


Compare databases fast, safe, free... DBTyP.NET - in version 2008 supports Oracle besides SQL Server and MySQL. DBTyP.NET 2008 is coming... in 3 weeks.

Saturday, February 2, 2008

Great Help Authoring Tool

We have just discovered and get impressed with Rolehelp. We are still testing different help authoring tools but this one with their simplicity, great user interface, feature reach capabilities and creation of 7 different help formats simply fascinate us. Of course, we have never wanted to spend 1000$ for such a tool, therefore Roledata offer of 59$ and free demo version with limitation of 50 topics is very, very attractive one. So, if you need fast, simple, free or at least cheap help authoring tool, visit them and you will get one great tool.
I'm sure we will use it in our data and schema compare solution in version 2008.




Synchronize and compare the structure and data of your SQL Server, Oracle, and MySQL databases - DBTyP.NET by BYPsoft

Tuesday, January 29, 2008

MSDN Launches Code Galery

We found very interesting and wanted to share it with all of you that MSDN launches yesterday Code Gallery dedicated to developers community for sharing samples, tools, articles, participating in discussions...
Code Gallery has been used till now by internal Microsoft employess for sharing code samples and tools and now is availalble to the community. Anyone with LIVE ID can post there. Let's see how this will work.

Sunday, January 27, 2008

Primary keys without "real" tables

Have you queried some when information_schema.table_constraints or sys.key_constraints to discover a primary keys in your database? And as a result from select * from information_schema.table_constraints you noticed that there are primary keys without TABLE_SCHEMA and TABLE_NAME in resultset?
You can be confused with this but the explanation is simple. Your primary keys defined in table-valued functions have been listed here. So if you have a function defined as

CREATE FUNCTION [dbo].[fnTest]
(
@foo int
)
returns @resultTable table (test1 int, test2 int primary key (test1))
as
begin
insert into @resultTable(test1, test2)
select 1, @foo

return
end

you will have as CONSTRAINT_NAME something like "PK__fnTest__2D27B809" and TABLE_SCHEMA and TABLE_NAME will be NULL.