Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
1) Make various type pattern replacements from MSRDO20.dll.xml, for example:
		OLD:	static RDO.rdoConnection conn = null;
		NEW:	static System.Data.SqlClient.SqlConnection conn = null;

		OLD:	conn = new RDO.rdoConnection();
		NEW:	conn = new System.Data.SqlClient.SqlConnection();

		OLD:	conn.Connect = dbs;
		NEW:	conn.ConnectionString = dbs;		

		OLD:	conn.EstablishConnection(null,null,null);
		NEW:	conn.Open();		

		OLD:	RDO.rdoQuery SP = null;
		NEW:	System.Data.SqlClient.SqlCommand SP = null;		

2) Transform the connection string (difficult to generalize; easily  done with authorfix or a runtime method)
		OLD:	dbs = "UID=stocks_login;PWD=password;Database=stocks;" + "Server=GMI-CS-01.gmi.local;Driver={SQL Server};" + "DSN='';";
		NEW:	dbs = "UID=stocks_login;PWD=password;Database=stocks;" + "Server=GMI-CS-01.gmi.local;";

3) Remove rdoResultSet as a variable and replace later with a temporary variable in a using statement
		OLD:	RDO.rdoResultset Results = null;

4) Remove the following (due to EOF -> Read() conversion)
		OLD:	Results.MoveNext();
		
5) Replace ? with incremented generic @# type parameters OR insert a runtime parser that replaces ? with @# typed parameters. 
Some care must be taken when considering that SQL strings can be built using various concat statements and variables. 
Our current sample and the issue provided by client did not include that scenerio.
		OLD:	SQL = "select * from accounts where accountID < ? and FirstName like ?";
		NEW:	SQL = "select * from accounts where accountID < @0 and FirstName like @1";

6) Params are not created by default.  We must add a new one, then assign its value. The parameter name 
 needs to correspond to the param index such that 0 becomes "0" and in the query ? becomes @0
		OLD:	SP.rdoParameters[0].Value = "5005";
		NEW:	SP.Parameters.Add(new System.Data.SqlClient.SqlParameter("0", null)).Value = "5005";

		OLD:	SP.rdoParameters[1].Value = "Test%";
		NEW:	SP.Parameters.Add(new System.Data.SqlClient.SqlParameter("1", null)).Value = "Test%";
		
7) CreateQuery must use the connection to create a command and then set its query statement.  
 This can be authored as 2 statements, but we felt it would be cleaner to migrate from 1 statement to 1 statement.
		OLD:	SP = conn.CreateQuery("QueryAcct",SQL);
		NEW:	(SP = conn.CreateCommand()).CommandText = SQL;


8) The Results variable declaration that was removed in operation 4), is instead declared in a C# 'using' block. 
That block ends after the last statement that uses the results variable: operation 9).
 
Also, rdoResultSet is type changed to SqlDataReader and the OpenResultSet call is changed to ExecuteReader
 
		OLD:	Results = SP.OpenResultset(RDO.ResultsetTypeConstants.rdOpenForwardOnly,null,null);
		NEW:	using (System.Data.SqlClient.SqlDataReader Results = SP.ExecuteReader())
		NEW:	{
		
			  By the way, the corresponding using statement in VB.NET is expressed as follows:  
			  
			  Using Results As System.Data.SqlClient.SqlDataReader = SP.ExecuteReader()
				 ...
			  End Using

9) Command.Close is not needed with a using block; just closing the block in .NET does a close/dispose implicitly.
		OLD:	SP.Close();
		NEW:	}
		
10) Results EOF property becomes the Read method.  The Boolean logic is reversed requiring the removal of the !.  
Because of the Read method the Results.MoveNext method is removed
		OLD:	while (!Results.EOF)
		NEW:	while (Results.Read())

11a) The rdoColumns collection reference is replaced with indexer this[string column] of the reader.
11b) The .Value is removed.  
		OLD:	f = Convert.ToString(Results.rdoColumns["FirstName"].Value);
		NEW:	f = Convert.ToString(Results["FirstName"]);
		
		OLD:	f = Convert.ToString(Results.rdoColumns["eMail"].Value);
		NEW:	f = Convert.ToString(Results["eMail"]);
 

...