خرید بک لینک

Vote count: 0

I want to insert a record in my RDV table.

There is the query creation of my table RDV:

CREATE TABLE [dbo].[RDV] (
[idRdv]       INT           NOT NULL,
[objet]       NVARCHAR (50) NULL,
[objectif]    NVARCHAR (50) NULL,
[DateRdv]     DATETIME      NULL,
[commentaire] NVARCHAR (50) NULL,
[archive]     NVARCHAR (50) NULL,
[idClient]    INT           NULL,
[idUser]      INT           NULL,
[idResultat]  INT           NULL,
CONSTRAINT [PK_RDV] PRIMARY KEY CLUSTERED ([idRdv] ASC),
FOREIGN KEY ([idClient]) REFERENCES [dbo].[Client] ([idClient]),
FOREIGN KEY ([idUser]) REFERENCES [dbo].[User] ([idUser]),
FOREIGN KEY ([idResultat]) REFERENCES [dbo].[Resultat] ([idResultat])

And below there is my code to insert in RDV Table:

private void button1_Click(object sender, EventArgs e)
    {
        string cmdStr = "Insert into RDV(idUser,idClient,objet,objectif,DateRdv,commentaire) select (@idUser,@idClient,@objet,@objectif,@DateRdv,@commentaire) from RDV Client User where RDV.idClient=idClient.Client and RDV.idUser=User.idUser ";
        SqlCoection con = new SqlCoection("Data Source=YOSRA-PC\SQLEXPRESS;Initial Catalog=timar;Integrated Security=True");
        SqlCommand cmd = new SqlCommand(cmdStr, con);
        cmd.Parameters.AddWithValue("@idUser", comboBox1.SelectedValue);
        cmd.Parameters.AddWithValue("@idClient", comboBox2.SelectedValue);
        cmd.Parameters.AddWithValue("@objet", textBox1.Text);
        cmd.Parameters.AddWithValue("@objectif", textBox2.Text);
        cmd.Parameters.AddWithValue("@DateRdv", dateTimePicker1.Value.ToString());
        cmd.Parameters.AddWithValue("@commentaire", textBox4.Text);

        con.Open();
        int LA = cmd.ExecuteNonQuery();
        Console.WriteLine("Ligne ajoutée: {0}", LA);

But it show me an Error: Incorrect Syntax to ','

I can't understand what it's wrong here??

Pleaaaaaaaaase, Help me.

asked 3 mins ago

1 Answer

Vote count: 0

Remove the parens:

select (@idUser,@idClient,@objet,@objectif,@DateRdv,@commentaire)

select @idUser,@idClient,@objet,@objectif,@DateRdv,@commentaire

answered 6 secs ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 21 ارديبهشت 1395 ساعت: 0:18

صفحه بندی