-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathProgram.cs
44 lines (42 loc) · 1.25 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using IoTSharp.Data.Taos;
namespace Demo
{
class Program
{
private static void Main()
{
var builder = new TaosConnectionStringBuilder()
{
DataSource = "127.0.0.1",
DataBase = "",
Username = "root",
Password = "taosdata",
Port = 6030
};
string configDir = "/etc/taos";
var connection = new TaosConnection(builder.ConnectionString, configDir);
try
{
connection.Open();
Console.WriteLine("Connected!");
var cmd = connection.CreateCommand();
Console.Write("Get server version: ");
cmd.CommandText = "select server_version()";
var res = cmd.ExecuteReader();
while (res.Read())
{
Console.WriteLine(res.GetString(0));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
connection.Close();
Console.WriteLine("Closed!");
}
}
}
}