Kreshnike Rahmani

Kreshnike Rahmani

  • NA
  • 14
  • 16.5k

Error during the execution of an sql comand in C#

Dec 25 2012 7:20 PM
Here down there is my code, when I execute it it says that I have an syntax error near GrupetStudentet, While thos query works very good on sql server, but when O write it on my code it says that I have a problem. PLs can somebudy help me if you know th answer. 


           string ID;
            ID = txtIDstudent.Text;


            string sql = "SELECT gs.Grupi_ID, (s.Emri + ' ' + s.Mbiemri) as Studenti, n.EmriNivelit as Niveli, k.EmriKursit as Kursi";
            sql +="FROM GrupetStudent gs";
            sql +="inner join Studenti s on gs.Studenti_ID = s.Studenti_ID";
            sql +="inner join Niveli n on gs.Nivel_ID = n.ID_nivelit";
            sql +="inner join Kursi k on gs.Kursi_ID = k.ID_kurs";
            sql +="WHERE s.Studenti_ID="+ID;


            if (txtIDstudent.Text == "")
            {
                MessageBox.Show("Ju lutem shënoni ID-në e studentit");
            }
            else
            {
                    SqlDataAdapter DaKerko = new SqlDataAdapter(sql, con);
                    DataTable dtKerko = new DataTable();
                    DaKerko.Fill(dtKerko);

Answers (2)