想得到数据所有支持的数据类型(GetSchema的使用)

代码
   
     
1 using System;
2   using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using WCFService2;
6 using System.Data;
7 using System.Data.OracleClient;
8 using System.ComponentModel;
9 using System.Data.SqlClient;
10 using System.Data.OleDb;
11 namespace testxcode
12 {
13 class Program
14 {
15 static void OutPut(DataRow dt, DataColumnCollection colCollection)
16 {
17 for ( int i = 0 ; i < colCollection.Count; i ++ )
18 {
19 Console.Write( " \r\n[ " + colCollection[i].ToString() + " ]: " + dt[i].ToString() + " \r\n " );
20
21 }
22 Console.Write( " ____________________________________________\r\n " );
23 }
24 static void Main( string [] args)
25 {
26 Console.WriteLine(XLog.XTrace.LogPath);
27 OracleConnection conntest = new OracleConnection( " Data Source=Local;user id=ws;password=MCenter.finfo.CC; " );
28 conntest.Open();
29 DataTable dttest = conntest.GetSchema();
30 foreach (DataRow row in dttest.Rows)
31 {
32 OutPut(row, dttest.Columns);
33 }
34 Console.Read();
35 return ;
36 // Console.WriteLine(Sys_config.Find(Sys_config._.Configkey, "SerHost").Configvalue);
37 OracleConnection conn = new OracleConnection( " Data Source=Local;user id=ws;password=MCenter.finfo.CC; " );
38 Console.WriteLine( " oracle11g " );
39 XLog.XTrace.WriteLine( " oracle11g " );
40 conn.Open();
41 DataTable dt = conn.GetSchema( " DATATYPES " );
42 foreach (DataRow item in dt.Rows)
43 {
44 Console.WriteLine(item[ 0 ].ToString() + " : " + item[ " DataType " ].ToString());
45 XLog.XTrace.WriteLine(item[ 0 ].ToString() + " : " + item[ " DataType " ].ToString());
46 }
47 conn.Close();
48 XLog.XTrace.WriteLine( " C#不支持的类型:binary_double,binary_float " );
49
50
51
52
53
54
55
56
57
58
59
60
61 SqlConnection sqlconn = new SqlConnection( " server=.;database=test;uid=sa;pwd=gaoshengjie " );
62 Console.WriteLine( " sqlserver2008 " );
63 XLog.XTrace.WriteLine( " sqlserver2008 " );
64 sqlconn.Open();
65 foreach (DataRow item in sqlconn.GetSchema( " DATATYPES " ).Rows)
66 {
67 Console.WriteLine(item[ 0 ].ToString() + " : " + item[ " DataType " ].ToString());
68 XLog.XTrace.WriteLine(item[ 0 ].ToString() + " : " + item[ " DataType " ].ToString());
69 }
70 sqlconn.Close();
71
72
73
74
75
76
77
78
79
80
81
82
83 OleDbConnection OleDbconn = new OleDbConnection( " Provider=Microsoft.Jet.OLEDB.4.0; Data Source=test.mdb;Persist Security Info=False; " );
84 Console.WriteLine( " ACCESS " );
85 XLog.XTrace.WriteLine( " ACCESS " );
86 OleDbconn.Open();
87 foreach (DataRow item in OleDbconn.GetSchema( " DATATYPES " ).Rows)
88 {
89 Console.WriteLine(item[ 0 ].ToString() + " : " + item[ " DataType " ].ToString());
90 XLog.XTrace.WriteLine(item[ 0 ].ToString() + " : " + item[ " DataType " ].ToString());
91 }
92 OleDbconn.Close();
93
94 Console.Read();
95 }
96 }
97 }
98

 

你可能感兴趣的:(schema)