Beispiel #1
0
        public void ConnectTDengine()
        {
            string db = "";

            this.conn = TDengine.Connect(this.host, this.user, this.password, db, this.port);
            if (this.conn == IntPtr.Zero)
            {
                Console.WriteLine("connection failed: " + this.host);
                ExitProgram();
            }
            else
            {
                Console.WriteLine("[ OK ] Connection established.");
            }
        }
Beispiel #2
0
        public void ConnectTDengine()
        {
            string db = "";

            this.conn = TDengine.Connect(this.host, this.user, this.password, db, this.port);
            if (this.conn == IntPtr.Zero)
            {
                Console.WriteLine("Connect to TDengine failed");
                ExitProgram();
            }
            else
            {
                Console.WriteLine("Connect to TDengine success");
            }
        }
Beispiel #3
0
        public void ConnectTDengine()
        {
            string db = "";

            VerbosePrintFormat("host:{0} user:{1}, pass:{2}; db:{3}, port:{4}\n",
                               this.host, this.user, this.password, db, this.port);
            this.conn = TDengine.Connect(this.host, this.user, this.password, db, this.port);
            if (this.conn == IntPtr.Zero)
            {
                Console.WriteLine("Connect to TDengine failed");
                CleanAndExitProgram(1);
            }
            else
            {
                VerbosePrint("Connect to TDengine success\n");
            }
        }
Beispiel #4
0
            protected override IntPtr OnCreate()
            {
                var connStr = ConnectionString;

                if (connStr.IsNullOrEmpty())
                {
                    throw new InvalidOperationException("未设置连接字符串");
                }

                var builder    = new ConnectionStringBuilder(connStr);
                var dataSource = builder["DataSource"] ?? builder["Server"];
                var port       = builder["Port"].ToInt();
                //if (port <= 0) port = 6030;

                var user = builder["username"] ?? builder["user"] ?? builder["uid"];
                var pass = builder["password"] ?? builder["pass"] ?? builder["pwd"];
                var db   = builder["database"] ?? builder["db"];

                var uri = new NetUri(dataSource);

                if (port > 0)
                {
                    uri.Port = port;
                }
#if DEBUG
                XTrace.WriteLine("连接TDengine:server={0};user={1};pass={2};db={3}", dataSource, user, pass, db);
#endif

                var handler = TD.Connect(uri.Address + "", user, pass, db, (Int16)uri.Port);
                if (handler == IntPtr.Zero)
                {
                    throw new XCodeException("打开数据库连接失败!");
                }

                return(handler);
            }