• CUBRID学习笔记 37 ADO.NET Schema Provider


    通常需要添加以下引用:

     
    1
    2
    3
    using System.Data;
    using System.Data.Common;
    using CUBRID.Data.CUBRIDClient;

    定义连接字符串:

     
    1
    2
    /* conection string, please modify before using. */
    string _connString = "server=localhost;database=demodb;port=33000;user=public;password=";

    用 CUBRIDConnectionStringBuilder生成连接字符串 这个我比较喜欢:

     
    1
    2
    3
    4
    5
    6
    7
    8
    string server = "localhost";
    int port = 33000;
    string database = "demodb";
    string user = "public";
    string password = "";
    string encoding = "utf-8";
    CUBRIDConnectionStringBuilder sb = new CUBRIDConnectionStringBuilder(server, port, database, user, password, encoding);
    string _connString = sb.GetConnectionString();

    获取用户表:

     
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    /* create a new CUBRIDConnection instance */
    using (CUBRIDConnection conn = new CUBRIDConnection())
    {
        try
        {
            /* set the connection string */
            conn.ConnectionString = _connString;
            /* connect to db server */
            conn.Open();
      
            /* create a new CUBRIDSchemaProvider instance */
            CUBRIDSchemaProvider schema = new CUBRIDSchemaProvider(conn);
            /* get all tables */
            DataTable dt = schema.GetTables(new string[] { "%" });
      
            /* print all tables */
            for (int i = 0; i < dt.Rows.Count; i++)
                Console.WriteLine(dt.Rowsi2.ToString());
        }
        catch (Exception exp)
        {
            Console.WriteLine(exp.Message);
        }
    }

    获取所有用户:

     
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    /* create a new CUBRIDConnection instance */
    using (CUBRIDConnection conn = new CUBRIDConnection())
    {
        try
        {
            /* set the connection string */
            conn.ConnectionString = _connString;
            /* connect to db server */
            conn.Open();
     
            /* create a new CUBRIDSchemaProvider instance */
            CUBRIDSchemaProvider schema = new CUBRIDSchemaProvider(conn);
            /* get all users */
            DataTable dt = schema.GetUsers(null);
     
            /* print all users */
            for (int i = 0; i < dt.Rows.Count; i++)
                Console.WriteLine(dt.Rowsi0.ToString().ToUpper());
        }
        catch (Exception exp)
        {
            Console.WriteLine(exp.Message);
        }
    }

    获取所有视图: 

     
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    /* create a new CUBRIDConnection instance */
    using (CUBRIDConnection conn = new CUBRIDConnection())
    {
        try
        {
            /* set the connection string */
            conn.ConnectionString = _connString;
            /* connect to db server */
            conn.Open();
     
            /* create a new CUBRIDSchemaProvider instance */
            CUBRIDSchemaProvider schema = new CUBRIDSchemaProvider(conn);
            /* get all tables */
            DataTable dt = schema.GetViews(new string[] { "%" });
     
            /* print all tables */
            for (int i = 0; i < dt.Rows.Count; i++)
                Console.WriteLine(dt.Rowsi2.ToString());
        }
        catch (Exception exp)
        {
            Console.WriteLine(exp.Message);
        }
    }
  • 相关阅读:
    poj3463 Sightseeing(最短路,次短路计数)
    poj3463 Sightseeing(读题很重要)
    poj3463 Sightseeing(读题很重要)
    hdu6181 Two Paths(次短路)
    hdu6181 Two Paths(次短路)
    Tyvj1293(新姿势:次短路)
    Tyvj1293(新姿势:次短路)
    10.bitset
    9.优先队列,priority_queue
    8.queue
  • 原文地址:https://www.cnblogs.com/wang2650/p/5288011.html
Copyright © 2020-2023  润新知