public static void Test_bulk_operation() { short operation = 0, res = 0; MarshalManage mb_int = new MarshalManage(4); MarshalManage mb_indicator = new MarshalManage(4); MarshalManage mb_data = new MarshalManage(16); st_odbc_record record2 = new st_odbc_record(); record2.indicator_ptr = mb_indicator.buffer; record2.data_ptr = mb_data.buffer; record2.table_name = "test"; record2.record_number = 1; MarshalManage mb_record2 = new MarshalManage(record2); st_odbc_record record = new st_odbc_record(); record.indicator_ptr = mb_indicator.buffer; record.data_ptr = mb_data.buffer; record.next = mb_record2.buffer; MarshalManage mb_record = new MarshalManage(record); st_odbc_connection conn = new st_odbc_connection(); MarshalManage mb_conn = new MarshalManage(conn); st_odbc_statement statement = new st_odbc_statement(); statement.conn = mb_conn.buffer; st_odbc_desc desc = new st_odbc_desc(); desc.rows_processed_ptr = mb_int.buffer; desc.max_count = 1; desc.array_size = 1; desc.records = mb_record.buffer; MarshalManage mb_array_status_ptr = new MarshalManage(16); desc.array_status_ptr = mb_array_status_ptr.buffer; MarshalManage mb_desc = new MarshalManage(desc); statement.apd = mb_desc.buffer; statement.ipd = mb_desc.buffer; statement.ard = mb_desc.buffer; statement.ird = mb_desc.buffer; res = SQLBulkOperations(ref statement, operation); operation = 5; res = SQLBulkOperations(ref statement, operation); operation = 4; res = SQLBulkOperations(ref statement, operation); operation = 6; res = SQLBulkOperations(ref statement, operation); operation = 7; res = SQLBulkOperations(ref statement, operation); }
public static void Test_bulk_operation() { short operation=0,res =0; MarshalManage mb_int = new MarshalManage(4); MarshalManage mb_indicator = new MarshalManage(4); MarshalManage mb_data = new MarshalManage(16); st_odbc_record record2 = new st_odbc_record(); record2.indicator_ptr = mb_indicator.buffer; record2.data_ptr = mb_data.buffer; record2.table_name = "test"; record2.record_number = 1; MarshalManage mb_record2 = new MarshalManage(record2); st_odbc_record record = new st_odbc_record(); record.indicator_ptr =mb_indicator.buffer; record.data_ptr = mb_data.buffer; record.next = mb_record2.buffer; MarshalManage mb_record= new MarshalManage(record); st_odbc_connection conn = new st_odbc_connection(); MarshalManage mb_conn = new MarshalManage(conn); st_odbc_statement statement = new st_odbc_statement(); statement.conn = mb_conn.buffer; st_odbc_desc desc = new st_odbc_desc(); desc.rows_processed_ptr = mb_int.buffer; desc.max_count = 1; desc.array_size = 1; desc.records = mb_record.buffer; MarshalManage mb_array_status_ptr= new MarshalManage(16); desc.array_status_ptr = mb_array_status_ptr.buffer; MarshalManage mb_desc = new MarshalManage(desc); statement.apd = mb_desc.buffer; statement.ipd = mb_desc.buffer; statement.ard = mb_desc.buffer; statement.ird = mb_desc.buffer; res = SQLBulkOperations(ref statement, operation); operation = 5; res = SQLBulkOperations(ref statement, operation); operation = 4; res = SQLBulkOperations(ref statement, operation); operation = 6; res = SQLBulkOperations(ref statement, operation); operation = 7; res = SQLBulkOperations(ref statement, operation); }
/// <summary> /// Test OdbcTransaction class /// </summary> /// public static void Test_GetDescField() { StringBuilder sb_length = new StringBuilder(16); StringBuilder sb_value = new StringBuilder(16); st_odbc_desc odbc_descFiel = new st_odbc_desc(); st_odbc_record record = new st_odbc_record(); record.record_number = 1; record.datetime_interval_code = 101; //将托管内存转换为非托管内存 MarshalManage mb = new MarshalManage(record); odbc_descFiel.records = mb.buffer; odbc_descFiel.alloc_type = 1; odbc_descFiel.array_size = 2; odbc_descFiel.bind_type = 3; odbc_descFiel.fetched_size = 5; odbc_descFiel.handle_type = 6; odbc_descFiel.max_count = 7; //调用非托管方法 //SQL_DESC_ALLOC_TYPE 1099 SQLGetDescField(ref odbc_descFiel, 1, 1099, sb_value, 16, sb_length); Assert.IsTrue(sb_value.ToString()[0] == 1); //SQL_DESC_ARRAY_SIZE 20 SQLGetDescField(ref odbc_descFiel, 1, 20, sb_value, 16, sb_length); Assert.IsTrue(sb_value.ToString()[0] == 2); //SQL_DESC_ARRAY_STATUS_PTR 21 SQLGetDescField(ref odbc_descFiel, 1, 21, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_BIND_OFFSET_PTR 24 SQLGetDescField(ref odbc_descFiel, 1, 24, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_BIND_TYPE 25 SQLGetDescField(ref odbc_descFiel, 1, 25, sb_value, 16, sb_length); Assert.IsTrue(sb_value.ToString()[0] == 3); //SQL_DESC_CASE_SENSITIVE 12 SQLGetDescField(ref odbc_descFiel, 1, 12, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_DATETIME_INTERVAL_CODE 1007 SQLGetDescField(ref odbc_descFiel, 1, 1007, sb_value, 16, sb_length); Assert.IsTrue(sb_value.ToString()[0] == 101); //SQL_DESC_DATETIME_INTERVAL_PRECISION 26 SQLGetDescField(ref odbc_descFiel, 1, 26, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_DISPLAY_SIZE 6 SQLGetDescField(ref odbc_descFiel, 1, 6, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_FIXED_PREC_SCALE 9 SQLGetDescField(ref odbc_descFiel, 1, 9, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_COLUMN_LENGTH 3 SQLGetDescField(ref odbc_descFiel, 1, 3, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_LITERAL_PREFIX 27 SQLGetDescField(ref odbc_descFiel, 1, 27, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_LITERAL_SUFFIX 28 SQLGetDescField(ref odbc_descFiel, 1, 28, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_LOCAL_TYPE_NAME 29 SQLGetDescField(ref odbc_descFiel, 1, 29, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_NUM_PREC_RADIX 32 SQLGetDescField(ref odbc_descFiel, 1, 32, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_PARAMETER_TYPE 33 SQLGetDescField(ref odbc_descFiel, 1, 33, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_SEARCHABLE 13 SQLGetDescField(ref odbc_descFiel, 1, 13, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_TYPE 1002 SQLGetDescField(ref odbc_descFiel, 1, 1002, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_UNNAMED 1012 SQLGetDescField(ref odbc_descFiel, 1, 1012, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_ROWVER 35 SQLGetDescField(ref odbc_descFiel, 1, 35, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); }
/// <summary> /// Test OdbcTransaction class /// </summary> /// public static void Test_GetDescField() { StringBuilder sb_length = new StringBuilder(16); StringBuilder sb_value = new StringBuilder(16); st_odbc_desc odbc_descFiel = new st_odbc_desc(); st_odbc_record record = new st_odbc_record(); record.record_number = 1; record.datetime_interval_code = 101; //将托管内存转换为非托管内存 MarshalManage mb = new MarshalManage(record); odbc_descFiel.records = mb.buffer; odbc_descFiel.alloc_type = 1; odbc_descFiel.array_size = 2; odbc_descFiel.bind_type = 3; odbc_descFiel.fetched_size = 5; odbc_descFiel.handle_type=6; odbc_descFiel.max_count = 7; //调用非托管方法 //SQL_DESC_ALLOC_TYPE 1099 SQLGetDescField(ref odbc_descFiel, 1, 1099, sb_value, 16, sb_length); Assert.IsTrue(sb_value.ToString()[0] == 1); //SQL_DESC_ARRAY_SIZE 20 SQLGetDescField(ref odbc_descFiel, 1, 20, sb_value, 16, sb_length); Assert.IsTrue(sb_value.ToString()[0] == 2); //SQL_DESC_ARRAY_STATUS_PTR 21 SQLGetDescField(ref odbc_descFiel, 1, 21, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_BIND_OFFSET_PTR 24 SQLGetDescField(ref odbc_descFiel, 1, 24, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_BIND_TYPE 25 SQLGetDescField(ref odbc_descFiel, 1, 25, sb_value, 16, sb_length); Assert.IsTrue(sb_value.ToString()[0] == 3); //SQL_DESC_CASE_SENSITIVE 12 SQLGetDescField(ref odbc_descFiel, 1, 12, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_DATETIME_INTERVAL_CODE 1007 SQLGetDescField(ref odbc_descFiel, 1, 1007, sb_value, 16, sb_length); Assert.IsTrue(sb_value.ToString()[0] == 101); //SQL_DESC_DATETIME_INTERVAL_PRECISION 26 SQLGetDescField(ref odbc_descFiel, 1, 26, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_DISPLAY_SIZE 6 SQLGetDescField(ref odbc_descFiel, 1, 6, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_FIXED_PREC_SCALE 9 SQLGetDescField(ref odbc_descFiel, 1, 9, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_COLUMN_LENGTH 3 SQLGetDescField(ref odbc_descFiel, 1, 3, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_LITERAL_PREFIX 27 SQLGetDescField(ref odbc_descFiel, 1, 27, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_LITERAL_SUFFIX 28 SQLGetDescField(ref odbc_descFiel, 1, 28, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_LOCAL_TYPE_NAME 29 SQLGetDescField(ref odbc_descFiel, 1, 29, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_NUM_PREC_RADIX 32 SQLGetDescField(ref odbc_descFiel, 1, 32, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_PARAMETER_TYPE 33 SQLGetDescField(ref odbc_descFiel, 1, 33, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_SEARCHABLE 13 SQLGetDescField(ref odbc_descFiel, 1, 13, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_TYPE 1002 SQLGetDescField(ref odbc_descFiel, 1, 1002, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_UNNAMED 1012 SQLGetDescField(ref odbc_descFiel, 1, 1012, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); //SQL_DESC_ROWVER 35 SQLGetDescField(ref odbc_descFiel, 1, 35, sb_value, 16, sb_length); Assert.IsTrue(sb_value.Length == 0); }