These methods are related to each other as you can see.
"students" table has general info about each student.
Some students are always absent, so no students_ID in "register" table.
And this cause for an error with da.Fill(dt).
How can I eliminate this error?
private string getUquvchilar_ID()
{
var fish = ddlName.Text.Replace("'", "''");
MySqlConnection con = new MySqlConnection(constr);
con.Open();
string query = "Select Students_ID from students where CONCAT(Familiyasi , ' ', Ismi , ' ', Sharifi)='" + fish + "'";
MySqlCommand cmd = new MySqlCommand(query);
cmd.Connection = con;
String s = (cmd.ExecuteScalar() ?? String.Empty).ToString();
con.Close();
return s;
}
private void BindGrid()
{
MySqlConnection con = new MySqlConnection(constr);
MySqlCommand cmd = new MySqlCommand("SELECT * FROM rasmlar where Rasm_ID in (" + String.Join(",", getImage_ID()) + ")", con);
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
gvImages.DataSource = dt;
gvImages.DataBind();
}
private List
{
List
MySqlConnection con = new MySqlConnection(constr);
con.Open();
string query = "Select bosh_rasm_ID, Tugal_rasm_ID from register where students_ID='" + getUquvchilar_ID() + "'";
MySqlCommand cmd = new MySqlCommand(query);
cmd.Connection = con;
MySqlDataReader reader = cmd.ExecuteReader();
if (reader != null && reader.HasRows)
{
foreach (DbDataRecord s in reader)
{
if (!reader.IsDBNull(reader.GetOrdinal("bosh_rasm_ID")))
i.Add(s.GetInt32(0));
else
i.Add(0);
if (!reader.IsDBNull(reader.GetOrdinal("Tugal_rasm_ID")))
i.Add(s.GetInt32(1));
else
i.Add(0);
}
}
return i;
}
Shashank PatilPosted Sep 18, 2015, 8:28 AM
abdujalil chulievPosted Sep 18, 2015, 8:21 AM
"You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1"
Francis SusaimichaelPosted Sep 18, 2015, 8:07 AM