diff options
Diffstat (limited to 'mcs/class/Mono.Data.SybaseClient')
-rw-r--r-- | mcs/class/Mono.Data.SybaseClient/test/SybaseTest.cs | 192 |
1 files changed, 96 insertions, 96 deletions
diff --git a/mcs/class/Mono.Data.SybaseClient/test/SybaseTest.cs b/mcs/class/Mono.Data.SybaseClient/test/SybaseTest.cs index 9edf13cba58..a3bb709db7b 100644 --- a/mcs/class/Mono.Data.SybaseClient/test/SybaseTest.cs +++ b/mcs/class/Mono.Data.SybaseClient/test/SybaseTest.cs @@ -444,55 +444,55 @@ namespace Test.Mono.Data.SybaseClient // used internally by ReadData() to read each result set static void ReadResult(IDataReader rdr, DataTable dt) - {
- // number of columns in the table
- Console.WriteLine(" Total Columns: " +
- dt.Rows.Count);
-
- // display the schema
- foreach (DataRow schemaRow in dt.Rows) {
- foreach (DataColumn schemaCol in dt.Columns)
- Console.WriteLine(schemaCol.ColumnName +
- " = " +
- schemaRow[schemaCol]);
- Console.WriteLine();
- }
-
- int nRows = 0;
- int c = 0;
- string output, metadataValue, dataValue;
- // Read and display the rows
- Console.WriteLine("Gonna do a Read() now...");
- while(rdr.Read()) {
- Console.WriteLine(" Row " + nRows + ": ");
-
- for(c = 0; c < rdr.FieldCount; c++) {
- // column meta data
- DataRow dr = dt.Rows[c];
- metadataValue =
- " Col " +
- c + ": " +
- dr["ColumnName"];
-
- // column data
- if (rdr.IsDBNull(c) == true)
- dataValue = " is NULL";
+ { + // number of columns in the table + Console.WriteLine(" Total Columns: " + + dt.Rows.Count); + + // display the schema + foreach (DataRow schemaRow in dt.Rows) { + foreach (DataColumn schemaCol in dt.Columns) + Console.WriteLine(schemaCol.ColumnName + + " = " + + schemaRow[schemaCol]); + Console.WriteLine(); + } + + int nRows = 0; + int c = 0; + string output, metadataValue, dataValue; + // Read and display the rows + Console.WriteLine("Gonna do a Read() now..."); + while(rdr.Read()) { + Console.WriteLine(" Row " + nRows + ": "); + + for(c = 0; c < rdr.FieldCount; c++) { + // column meta data + DataRow dr = dt.Rows[c]; + metadataValue = + " Col " + + c + ": " + + dr["ColumnName"]; + + // column data + if (rdr.IsDBNull(c) == true) + dataValue = " is NULL"; else if ((Type) dr["DataType"] == typeof (byte[])) dataValue = ": 0x" + BitConverter.ToString ((byte[]) rdr.GetValue (c)).Replace ("-", "").ToLower (); - else
- dataValue =
- ": " +
- rdr.GetValue(c);
-
- // display column meta data and data
- output = metadataValue + dataValue;
- Console.WriteLine(output);
- }
- nRows++;
- }
- Console.WriteLine(" Total Rows Retrieved: " +
+ else + dataValue = + ": " + + rdr.GetValue(c); + + // display column meta data and data + output = metadataValue + dataValue; + Console.WriteLine(output); + } + nRows++; + } + Console.WriteLine(" Total Rows Retrieved: " + nRows); } @@ -505,36 +505,36 @@ namespace Test.Mono.Data.SybaseClient Console.WriteLine("IDataReader has a Null Reference."); } else { - do {
- DataTable dt = rdr.GetSchemaTable();
- if(rdr.RecordsAffected != -1) {
- // Results for
- // SQL INSERT, UPDATE, DELETE Commands
- // have RecordsAffected >= 0
- Console.WriteLine("Result is from a SQL Command (INSERT,UPDATE,DELETE). Records Affected: " + rdr.RecordsAffected);
- }
- else if(dt == null)
- // Results for
- // SQL Commands not INSERT, UPDATE, nor DELETE
- // have RecordsAffected == -1
- // and GetSchemaTable() returns a null reference
- Console.WriteLine("Result is from a SQL Command not (INSERT,UPDATE,DELETE). Records Affected: " + rdr.RecordsAffected);
- else {
- // Results for
- // SQL SELECT Queries
- // have RecordsAffected = -1
- // and GetSchemaTable() returns a reference to a DataTable
- Console.WriteLine("Result is from a SELECT SQL Query. Records Affected: " + rdr.RecordsAffected);
-
- results++;
- Console.WriteLine("Result Set " + results + "...");
-
- ReadResult(rdr, dt);
- }
-
- } while(rdr.NextResult());
- Console.WriteLine("Total Result sets: " + results);
-
+ do { + DataTable dt = rdr.GetSchemaTable(); + if(rdr.RecordsAffected != -1) { + // Results for + // SQL INSERT, UPDATE, DELETE Commands + // have RecordsAffected >= 0 + Console.WriteLine("Result is from a SQL Command (INSERT,UPDATE,DELETE). Records Affected: " + rdr.RecordsAffected); + } + else if(dt == null) + // Results for + // SQL Commands not INSERT, UPDATE, nor DELETE + // have RecordsAffected == -1 + // and GetSchemaTable() returns a null reference + Console.WriteLine("Result is from a SQL Command not (INSERT,UPDATE,DELETE). Records Affected: " + rdr.RecordsAffected); + else { + // Results for + // SQL SELECT Queries + // have RecordsAffected = -1 + // and GetSchemaTable() returns a reference to a DataTable + Console.WriteLine("Result is from a SELECT SQL Query. Records Affected: " + rdr.RecordsAffected); + + results++; + Console.WriteLine("Result Set " + results + "..."); + + ReadResult(rdr, dt); + } + + } while(rdr.NextResult()); + Console.WriteLine("Total Result sets: " + results); + rdr.Close(); } } @@ -601,15 +601,15 @@ namespace Test.Mono.Data.SybaseClient Console.WriteLine("\t\tCall ExecuteReader with a SQL Command. (Is INSERT,UPDATE,DELETE)."); reader = SelectDataUsingInsertCommand(cnc); ReadData(reader); -
- // Call a Stored Procedure named Version()
- Console.WriteLine("\t\tCalling stored procedure sp_server_info()");
- object obj = CallStoredProcedure(cnc);
- Console.WriteLine("Result: " + obj);
-
- Console.WriteLine("Database Server Version: " +
- ((SybaseConnection)cnc).ServerVersion);
-
+ + // Call a Stored Procedure named Version() + Console.WriteLine("\t\tCalling stored procedure sp_server_info()"); + object obj = CallStoredProcedure(cnc); + Console.WriteLine("Result: " + obj); + + Console.WriteLine("Database Server Version: " + + ((SybaseConnection)cnc).ServerVersion); + /* Clean up */ Console.WriteLine ("Clean up..."); Console.WriteLine ("\t\tDrop table..."); @@ -621,13 +621,13 @@ namespace Test.Mono.Data.SybaseClient } } - [STAThread]
- static void Main(string[] args)
- {
- string connectionString = "";
-
- if(args.Length == 3 || args.Length == 4) {
- if(args.Length == 3) {
+ [STAThread] + static void Main(string[] args) + { + string connectionString = ""; + + if(args.Length == 3 || args.Length == 4) { + if(args.Length == 3) { connectionString = String.Format( "Server={0};" + "Database={1};" + @@ -647,11 +647,11 @@ namespace Test.Mono.Data.SybaseClient Console.WriteLine("Usage: mono SybaseTest.exe sql_server database user_id password"); return; } -
- SybaseConnection cnc = new SybaseConnection ();
- cnc.ConnectionString = connectionString;
-
- cnc.Open();
+ + SybaseConnection cnc = new SybaseConnection (); + cnc.ConnectionString = connectionString; + + cnc.Open(); DoSybaseTest(cnc); cnc.Close(); } |