The obscure way to open an Access 97 database with MDW Security in Access2010

10. May 2012 12:38 by Mrojas in Access  //  Tags: , , , , ,   //   Comments (0)

I was in an AccessMigration to SQL Server and i needed to open an Access97 database with security (using a system.mdw file).

It took me a while to do, but it is possible to open an Access97 Database in Access2010.

I really thing that it is a little obscure. But these are the steps:

1. First open Access2010

2. After Opening Access2010, press Ctrl + G. That will open the Microsoft Visual Basic for Applications window.

3. On the Immediate Window run this command (to run it just time the command and press Enter): DoCmd.RunCommand acCmdWorkgroupAdministrator

4. Once you run this command you will see a dialog with a title of Workgroup Administrator, press the Join Button

  

5. When you press the join Button a Dialog with Title Workgroup Information File will prompt Click Browse and find your System.mdw file and press OK. And press Ok on the Workgroup Administrator Dialog

6. Now close Access 2010

7. Open Windows explorer. Find your .mdb file and double click it. Access2010 will prompt for user/password and then will upgrade your database.

Migrating the CommonDialog print dialog

2. March 2012 15:06 by Mrojas in Printing, VB6 Migration  //  Tags: , , , ,   //   Comments (0)

In VB6 you could use the commondialog to show several of the 
standard operating system dialogs. For example show the a 
the print setup dialog box or the print dialog box.

VB6 Example showing the Print Setup Dialog Box

cdlgprint.Flags = cdlPDPrintSetup

    cdlgprint.ShowPrinter

In .NET you have 4 kinds of Priting Dialogs:

PageSetupDialog

PrintDialog

PrintDocument

PrintPreviewDialog

 

So during a migration remember that if your were using the the CommonDialog.Flags 

property to show the PrintSetupDialog you will have to change that for something like

 

var cdlgprint_ForPrintSetup  = new PrintSetupDialog();

 cdlgprint_ForPrintSetup.Print()

BEWARE of FileSystem.FilePutObject

29. February 2012 15:45 by Mrojas in File, VB6 Migration  //  Tags: , , , , , , ,   //   Comments (0)

When you are migrating from VB6 to VB.NET most of the Put statements will be migrated to 

FileSystem.FilePutObject http://msdn.microsoft.com/en-us/library/z07he9as.aspx

The problem with this is that if you need that the files generated by your application to be compatible byte per byte
with your VB6 generated files you must put special attention.

Take a look at this example: 

Module Module1

    Sub Main()
              Dim str = "TEXTDATA"
              FileSystem.FileOpen(1, "c:\temp\file1.dat", OpenMode.Random, OpenAccess.Write, , 30)
              FileSystem.FilePutObject(1, str, 2)
              FileSystem.FileClose(1)
    End Sub

End Module

 

Module Module1

    Sub Main()
              Dim str = "TEXTDATA TEXTDATA TEXTDATA"
              FileSystem.FileOpen(1, "c:\temp\file1.dat", OpenMode.Random, OpenAccess.Write, , 30)
              FileSystem.FilePut(1, str, 2)
              FileSystem.FileClose(1)
    End Sub

End Module

 

The difference might seem minimal but it can be hard to detect.

The different byte is caused by using the FilePutObject instead of FilePut method


VB6 Migration, HTML5 Forms and ASP.NET Web Forms

16. February 2012 11:02 by Mrojas in HTML5, VB6 Migration  //  Tags: , , , , , , ,   //   Comments (0)

VB6 Migration, HTML5 Forms and ASP.NET Web Forms

If you come from a VB6 background, and your application is still in VB6,
you are probably wondering that this might be a good time to move out of VB6.

But is also a complex time. Which is right path: WinForms, Silverlight, WPF, HTML5?

Choosing the right target platform can be very tricky and depends on many varaiables.
So let's assume in this post that you have already decided that you want to use Web Tecnologies
and why not HTML5 as well.

ASP.NET Web Forms is a good technologie and developing forms with it is also very easy,
but can you develop HTML5 applications with this?

Well Brandon Satrom has a nice column in MSDN Magazine about Web Forms with HTML5 Forms.
He says:


If you’re planning to do HTML5 Forms development with ASP.NET Web Forms, there’s good news:
Many HTML5-related updates to .NET and Visual Studio are being released out-of-band, so you
don’t have to wait for the next framework version to use these features today.

To get started with HTML5 Forms and ASP.NET Web Forms, you’ll need to grab a couple of updates.
 First, make sure you have Visual Studio 2010 SP1 (bit.ly/nQzsld).
In addition to adding support for new HTML5 input types and attributes, the service pack also
provides some updates that enable you to use the new HTML5 input types on the TextBox server control.
Without this update, you’d see compile-time errors when using the new types.

You’ll also want to grab the Microsoft .NET Framework 4 Reliability Update 1 (bit.ly/qOG7Ni).
This update is designed to fix a handful of problems related to using the new HTML5 input types
with ASP.NET Web Forms. Scott Hunter covers a few of those—UpdatePanel, Validation Controls
and Callbacks—in a blog post from early August that you can check out at bit.ly/qE7jLz.

Update:

Mobilize.NET and Artinsoft.com company now helps in the HTML5 migration problem from VB6, Windows Forms and PowerBuilder. http://mobilize.net/default.aspx

 

Migrating Access to SQL Server

10. February 2012 17:51 by Mrojas in Access, SQL Server  //  Tags: , , , , ,   //   Comments (0)

If during a VB6 migration you decide o take a step forward and move your databases to MS SQL

don't worry. The SQL Server team has a tool just for that.

I just don't know why it is so hard to find it in google. But the appropiate link is:

http://blogs.msdn.com/b/ssma/p/access.aspx

Also a recent article in Teched goes into all the gory details: http://technet.microsoft.com/en-us/magazine/hh334645.aspx

Good Luck and don't hesitate to contact us for any doubts.

Running Object Table and .NET

30. September 2011 10:27 by Mrojas in General  //  Tags: , , , , , , , , ,   //   Comments (0)

What is the ROT?

“Using ROT (Running Object Table) is a great way to establish interprocess communication between two windows applications. From a purely logical aspect, one application registers a pointer to an instance of a class in the ROT, the other one gets a pointer pointing to the same instance of the registered class and therefore can use the same instance of the class via this pointer. The class that is registered has to be a COM class, otherwise it can be written in any language. The application that will retrieve the pointer from the ROT can be written in any language that can use COM, as ROT gives a pointer to a COM interface.”

Can it be implemented in .NET?

Sure a .NET application can be exposed thru COM and then its pointer can be gotten and consumed by other applications querying the ROT.

And excelent example can be found here: http://www.codeproject.com/KB/COM/ROTStuff.aspx

As always it has its caveats. Be careful.

Obvious replacement?

Well if what you want is (Interprocess Communication) IPC,there are several options in .NET :

* Classical .NET remoting which is very simple and stable to

* Named Pipes see an example here http://bartdesmet.net/blogs/bart/archive/2007/04/12/getting-started-with-named-pipes.aspx

* or WCF with Named Pipes, an example here http://www.codeproject.com/KB/WCF/WCF_CommOptions_part1.aspx

WCF can be an interesting option specially if we were doing things like DCOM and Remote monikers.

Ohhh Glorious Silverlight Theming!!

27. September 2011 03:14 by Mrojas in General  //  Tags: , , , , ,   //   Comments (0)

I’m very fond of one of our newest products www.silverlightmigration.com Smile

It provides a way to refresh your applications to take full advantage of XAML,
solves deployment issues, runs in Windows, Mac OSX and in some Linux with
MoonLight

And we are event tuning it up for the next jump: Windows 8… keep tuned for that.

One of the things a like most about this solution is XAML theming.

In general there are good themes but today I would like to recommend the SystemColors theme
from http://blogs.msdn.com/b/corrinab/archive/2010/04/12/9994045.aspx

You can download it from here.
This theme allows you to style all core, sdk and toolkit controls so they will use the theme that
you currently have in Windows. These might be very useful for some LOB applications,
so the applications can see more like native applications, and with the advent of Silverlight 5 and more
native integration, better Out-of-Browser execution I think it is just fine.

See some screen shots:

More on iOS / XCode / Objective-C Migration Methods and Multiple Parameters to C#

6. May 2011 03:16 by Mrojas in General  //  Tags: , , , , , , , , , , , , , , ,   //   Comments (0)

On a previous post I was describing how some basic Objective-C elements were mapped to C#.
In particular I showed how the @interface and @implementation definitions are to be mapped in .Net, including basic properties.
In this post I will show a little about how methods are migrated.

There are several things to analyze when moving Objective-C code to C# it might be simple but can be a complicated
task. Objective-C is a language created under the inspiration of SmallTalk. And in Smalltalk programmer do not think of
method calls but instead of message sending and that is something to keep in mind when doing this migration.
Also all methods are virtual and even if there are access restriction in Objective-C I will map those methods to
public for simplicity sake.

In the previous post we had:

FIRSTFIRST

Fraction.h
#import <Foundation/NSObject.h>
@interface Fraction: NSObject {
    int numerator;
    int denominator;
}
-(void) print;
-(void) setNumerator: (int) n;
-(void) setDenominator: (int) d;
-(int) numerator;
-(int) denominator;
@end

And

Fraction.m

#import "Fraction.h"
#import <stdio.h>

@implementation Fraction
-(void) print {
    printf( "%i/%i", numerator, denominator );
}

-(void) setNumerator: (int) n {
    numerator = n;
}

-(void) setDenominator: (int) d {
    denominator = d;
}

-(int) denominator {
    return denominator;
}

-(int) numerator {
    return numerator;
}
@end

And that example shows properties and methods with no parameter. OK. Now lets just focus on methods with 0, 1 and more parameters.

MethodsExample.h

#import <Foundation/NSObject.h>
@interface MethodsExample: NSObject {

}
-(void) print;
-(int) multiplyByTwo: (int) n ;
-(void) multiplyTwoNumers: (int) a andSecondNumber: b;
@end
 
MethodsExample.m
#import "MethodsExample.h"
#import <stdio.h>

@implementation MethodsExample
-(void) print {
    printf( "Hola mundo\n" );
}

-(int) multiplyByTwo: (int) n {
    return n * 2;
} -(int) multiplyTwoNumbers: (int) a andSecondNumber (int) b { return a * b;
} @end
And calling those functions will be:
#import <stdio.h>
#import "MethodsExample.h"

int main( int argc, const char *argv[] ) {
    // create a new instance
    MethodsExample *m = [[MethodsExample alloc] init];
    [m print]; 
int result; result = [m multiplyByTwo: 1]; result = [m multiplyTwoNumbers: 1 andSecondNumber: 5]; // free memory [m release]; return 0; }
This little example shows some of the particularities of Objective-C. 
In Objetive-C all parameters starting from the second parameter can have
what is called a label and labels are similar to namedParameter. Ok lets go ahead and map that class.
using System;

public class MethodsExample
{
    public virtual print() {
        Console.WriteLine("Hola mundo\n");
    }
    public virtual int multiplyByTwo(int n)
    {
      return n * 2;
    }
    //AproachOne
    public virtual int multiplyTwoNumber(int a,int andSecondNumber)
    {
        return a * andSecondNumber;
    }
    //AproachTwo
    //I just renamed as multiplyTwoNumber2 to avoid compilation errors.
    //The idea is that you will choose one of the two aproaches
    //or define a criteria for the instances where aproach one should be used
    //instead of approach two
    public virtual int multiplyTwoNumber(int a,int andSecondNumber)
    {
        int n = andSecondNumber;
        //This aproach will be better if you have a lot of code in the method
        //and you prefer to keep the original arg name
        return a * n;
    }

}
So the thing here is what to use as the parameter name, the label or the argument name. 
In the example you can see the two approaches in the multiplyTwoNumbers case.
 And calling the methods is simple and the named parameters syntax can be exploited.
using System;

public static class Program
{
    public static int Main(string[] argv ) {
        // create a new instance
        var m = new MethodsExample();
        m.print();
        int result;
        result = m.multiplyByTwo(1);
        result = m.multiplyTwoNumbers(1,andSecondNumber: 5); //using named parameters
        // free memory
        m.release();
        return 0;
    }
}
REMEMBER: This is just a glimpse of some mapping concepts from Objective-C to C#. 
There are many subtle details in this kind of migration and is my belief that only
an automated tool is able to process all those details in an effectively and more error-free
than a manual approach. For example in objective-c if m is null that will not cause any error if you
do something like [m print] and in C# that will throw an error. However a migration tool could determine
if the variable will have a value before its use and avoid adding unnecessary if (m!=null) statements.
We will examine this and other details in following posts. I hope this little examples give you enough information

for playing around migrating some Objective-C code. And if it gets too complicated just send me an email!!!

Porting Application from iOS to WP7C#. Some toughts migration of Objective-C to C#

29. April 2011 12:07 by Mrojas in WP7  //  Tags: , , , , , , , , , , , , ,   //   Comments (0)

Windows Phone 7 (WP7) is out! and it’s a great platform for developing new Apps. After being involved with Silverlight for a while
I am glad to have now the option to deploy apps to Windows Phone 7.

But we have to recognize that there are tons of great Apps for iPhone already. You might even have some of them.
So it’s porting time. Here at Artinsoft we love to upgrade/port application to all platforms.
So I will provide here some basic thoughts to help you upgrade your code.

For this post let’s discuss a little about applications written for XCode.

XCode applications are written in Objetive-C.Let’s map some examples:

In Objective-C your class will be usually

#import <Foundation/NSObject.h>
#import <Foundation/NSObject.h>

@interface Fraction: NSObject {
    int numerator;
    int denominator;
}

-(void) print;
-(void) setNumerator: (int) n;
-(void) setDenominator: (int) d;
-(int) numerator;
-(int) denominator;
@end
How you should understand that? Well this is just the list of methods in your class something like:
using System;
public class Fraction {    
    int _numerator;    
    int _denominator;    
    public void print() { /* TODO*/}     
    public int numerator   { get { /* TODO */ } set { /*TODO*/} }    
    public int denominator { get { /* TODO */ } set { /*TODO*/} }
}
The code for these methods will be in the .m file.
#import "Fraction.h"
#import <stdio.h>

@implementation Fraction
-(void) print {
    printf( "%i/%i", numerator, denominator );
}

-(void) setNumerator: (int) n {
    numerator = n;
}

-(void) setDenominator: (int) d {
    denominator = d;
}

-(int) denominator {
    return denominator;
}

-(int) numerator {
    return numerator;
}
@end
So that will complement your class implementation for something like:
using System;
public class Fraction 
{    
    int _numerator;    
    int _denominator;    
    public void print() 
    { 
        Console.Write("{0}/{1}" ,numerator,denominator);
    }     
    public int numerator     
    {         
        get { return _numerator; }        
        set { _numerator = value; }    
    }    
    public int denominator     
    {        
        get { return _denominator; }       
        set { _denominator = value; }    
    }
}
Ok An now let’s look at the Objective-C main.m:
#import <stdio.h>
#import "Fraction.h"

int main( int argc, const char *argv[] ) {
    // create a new instance
    Fraction *frac = [[Fraction alloc] init];
    Fraction *frac2 = [[Fraction alloc] init];

    // set the values
    [frac setNumerator: 1];
    [frac setDenominator: 3];

    // combined set
    [frac2 setNumerator: 1 andDenominator: 5];

    // print it
    printf( "The fraction is: " );
    [frac print];
    printf( "\n" );

    // print it
    printf( "Fraction 2 is: " );
    [frac2 print];
    printf( "\n" );

    // free memory
    [frac release];
    [frac2 release];

    return 0;
}
 
Which can be rewritten in C# as:
 
using System;
static class ProgramMain{static int Main(string[] argv) {
    // create a new instance
    Fraction frac = new Fraction();
    // set the values frac.Numerator = 1; frac.Denominator = 3;
    // print it
    Console.Write( "The fraction is: " );
    frac.print();    Console.Write( "\n" );
    // free memory frac = null;
    return 0;
}}
Well this is just for warming up. In following posts we will be looking 
at more Objective-C \ XCode concept mapping to C#.
I recommend looking at the site http://wp7mapping.interoperabilitybridges.com/ 
that provides a lot about mapping iOS API
 

Windows Azure Migration: Database Migration, Post 1

2. April 2011 18:14 by Mrojas in Azure  //  Tags: , , , , , , , , , ,   //   Comments (0)

WheWhen you are doing an azure migration, one of the first thing you must do is
collect all the information you can about your database.
Also at some point in your migration process you might consider between migration to
SQL Azure or Azure Storage or Azure Tables.

Do do all the appropriate decisions you need to collect at least basic data like:

  • Database Size
  • Table Size
  • Row Size
  • User Defined Types or any other code that depends on the CLR
  • Extended Properties

Database Size

You can use a script like this to collect some general information:

create table #spaceused(
databasename varchar(255),
size varchar(255),
owner varchar(255),
dbid int,
created varchar(255),
status varchar(255),
level int)

insert #spaceused (databasename , size,owner,dbid,created,status, level)  exec sp_helpdb

select * from #spaceused for xml raw
drop table  #spaceused
 

When you run this script you will get an XML like:

<row databasename="master" 
size=" 33.69 MB" 
owner="sa" 
dbid="1" 
created="Apr 8 2003" 
status="Status=ONLINE, ..." 
level="90"/>
<row databasename="msdb" 
size=" 50.50 MB" 
owner="sa" 
dbid="4" 
created="Oct 14 2005" 
status="Status=ONLINE, ..." 
level="90"/>
<row databasename="mycooldb" 
size=" 180.94 MB" 
owner="sa" 
dbid="89" 
created="Apr 22 2010" 
status="Status=ONLINE, ..." 
level="90"/>
<row databasename="cooldb" 
size=" 10.49 MB" 
owner="sa" 
dbid="53" 
created="Jul 22 2010" 
status="Status=ONLINE, ..." 
level="90"/>
<row databasename="tempdb" 
size=" 398.44 MB" 
owner="sa" dbid="2" 
created="Feb 16 2011" 
status="Status=ONLINE, ..." 
level="90"/>

And yes I know there are several other scripts that can give you more detailed information about your database
but this one answers simple questions like

Does my database fits in SQL Azure?
Which is an appropriate SQL Azure DB Size?

Also remember that SQL Azure is based on SQL Server 2008 (level 100).

80 = SQL Server 2000

90 = SQL Server 2005

100 = SQL Server 2008


If you are migrating from an older database (level 80 or 90) it might be necessary to upgrade first.

This post might be helpful: http://blog.scalabilityexperts.com/2008/01/28/upgrade-sql-server-2000-to-2005-or-2008/

Table Size

Table size is also important.There great script for that:

http://vyaskn.tripod.com/sp_show_biggest_tables.htm

If you plan to migrate to Azure Storage there are certain constraints. For example consider looking at the number of columns:

You can use these scripts: http://www.novicksoftware.com/udfofweek/vol2/t-sql-udf-vol-2-num-27-udf_tbl_colcounttab.htm (I just had to change the alter for create)

Row Size

I found this on a forum (thanks to Lee Dice and Michael Lee)

DECLARE @sql        VARCHAR (8000)
        , @tablename  VARCHAR (255)
        , @delim      VARCHAR (3)
        , @q          CHAR (1)

  SELECT @tablename = '{table name}'
       , @q         = CHAR (39)

  SELECT @delim = ''
       , @sql   = 'SELECT '

  SELECT @sql   = @sql
                + @delim
                + 'ISNULL(DATALENGTH ([' + name + ']),0)'
       , @delim = ' + '
  FROM   syscolumns
  WHERE  id = OBJECT_ID (@tablename)
  ORDER BY colid

  SELECT @sql = @sql + ' rowlength'
              + ' FROM [' + @tablename + ']'
       , @sql =  'SELECT MAX (rowlength)'
              + ' FROM (' + @sql + ') rowlengths'
  PRINT @sql
  EXEC (@sql)

Remember to change the {table name} for the name of the table you need

User Defined Types or any other code that depends on the CLR

Just look at your db scripts at determine if there are any CREATE TYPE statements with the assembly keyword.
Also determine if CLR is enabled with a query like:

select * from sys.configurations where name = 'clr enabled'

If this query has a column value = 1 then it is enabled.

Extended Properties

Look for calls to sp_addextendedproperty dropextendedproperty OBJECTPROPERTY and sys.extended_properties  in your scripts.