1. It is returning only two values of Image_ID1, Image_ID2 columns from a single row;
I want "getImage_ID()" method to give back several Image ID numbers like 10,45,65,79,103 etc...
and BindGrid() to return several images with these ID's.
2. "getImage_ID()" method is returning "ERROR" if any of these two columns has NULL value
Please help me giving specific examples.
private void BindGrid()
{
MySqlConnection con = new MySqlConnection(constr);
MySqlCommand cmd = new MySqlCommand("SELECT * FROM images where Image_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 Image_ID1,Image_ID2 from register where student_ID='" + getStudents_ID() + "'";
MySqlCommand cmd = new MySqlCommand(query);
cmd.Connection = con;
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
foreach (DbDataRecord s in reader)
{
i.Add(s.GetInt32(0));
i.Add(s.GetInt32(1));
}
}
reader.Close();
return i;
}
abdujalil chulievPosted Sep 17, 2015, 1:06 AM
abdujalil chulievPosted Sep 17, 2015, 12:57 AM
Manas MohapatraPosted Sep 16, 2015, 2:59 PM
abdujalil chulievPosted Sep 16, 2015, 2:42 PM
Image_ID1 Image_ID2
1 NULL
2 NULL
4 NULL
5 6
MySqlException Error appears saying:
"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"
Case II
Image_ID1 Image_ID2
1 NULL
2 3
4 NULL
5 6
Result is 5 and 6.
Case III
Image_ID1 Image_ID2
1 99
2 3
4 NULL
5 6
Result is 2,3,5,6.
Case IV
Image_ID1 Image_ID2
1 99
2 3
4 96
5 6
Result is 2,3,4,96,5,6.
It is not returning any single value and first pair values.
Am I missing some basic concepts?
Manas MohapatraPosted Sep 16, 2015, 11:21 AM