using System using System Collections Generic using System Linq using

 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
45
46
47
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data;
using MySql.Data.MySqlClient;
using NpgsqlTypes;
using Npgsql;
namespace modulTolya
{
class Program
{
static void Main(string[] args)
{
String concString = "Server = 10.64.6.9; uid=st_fcit; database=university; port=3306; password=111111";
MySqlConnection conn = new MySqlConnection(concString);
conn.Open();
String connStr = "SELECT * FROM curator";
MySqlCommand comm = new MySqlCommand(connStr, conn);
NpgsqlConnection connN;
string connstring = "Server=10.64.6.9;Port=5432;User Id=st_fcit; Password=111111;Database=university;";
connN = new NpgsqlConnection(connstring);
connN.Open();
var createtable = new NpgsqlCommand("CREATE table report ( curatorID int not null, personID int not null)", connN);
createtable.ExecuteNonQuery();
MySqlDataReader reader = comm.ExecuteReader();
while (reader.Read())
{
NpgsqlCommand dbcmd = connN.CreateCommand();
string comIns = "INSERT INTO report_tolya(curatorID, personID ) VALUES (" + reader["curatorID"].ToString() + "," + reader["personID"].ToString() + " )";
dbcmd.CommandText = comIns;
dbcmd.ExecuteNonQuery();
Console.WriteLine(reader["curatorID"]);
Console.WriteLine(reader["personID"]);
}
conn.Close();
connN.Close();
}
}
}