Bonjour à tous,

je travaille actuellement sur une application en c# qui permets de récupérer des données d'une base de donnée Postgresql et les insère dans une autre BDD Postgresql.
voici mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
namespace insert
{
    class Program
    {
        static void Main(string[] args)
        {
 
 
                    string connString = "DSN=pg_prd;Database=RPD;User Id=postgres;Password=*****;";
                    OdbcConnection conn = new OdbcConnection(connString);
                  OdbcCommand command = conn.CreateCommand();
                    command.CommandText = "Select etb,nobl,poidsb from t_thisdet";
                    conn.Open();
 
                   OdbcDataAdapter MyAdapter = new OdbcDataAdapter();
                    MyAdapter.SelectCommand = command;
                    DataSet dset = new DataSet("t_thisdet");
                    DataTable ds1 = new DataTable("ds1");
                    MyAdapter.Fill(ds1);
                    conn.Close();
 
 
                    string conn1String = "DSN=testing;Database=RPD;User Id=postgres;Password=****;";
                    OdbcConnection conn1 = new OdbcConnection(conn1String);
                    OdbcCommand command2 = conn1.CreateCommand();
                    conn1.Open();
                 for (int k = 1; k < ds1.Rows.Count; k++)
                    {
 
                 	string etb= ds1.Rows[k][@"etb"].ToString();
                 	string nobl = ds1.Rows[k][@"nobl"].ToString();
                 	string poidsb = ds1.Rows[k][@"poidsb"].ToString();
 
 
                       command2.CommandText="insert into hisdet values ('"+etb+"',"+nobl+","+poidsb+")";
 
 
                       command2.ExecuteNonQuery();
 
 
                 }
 
 
                    conn1.Close();
 
                }
Lors de mon exécution de mon code j'ai l'erreur suivante :
System.Data.Odbc.OdbcException: ERROR [42601] ERROR: INSERT has more expressions than target columns;
Error while executing the query

Alors que la structure de la requête sélect est égale à la structure de la requête inserte.
Est ce que vous avez des idées ?

Merci de votre aide