vinod jangir

vinod jangir

  • NA
  • 114
  • 9.2k

i get data from database

Sep 28 2015 3:27 AM
try
{
if (comboBox1.SelectedIndex >= 0)
{
if (con.State == ConnectionState.Closed)
con.Open();
da = new SqlDataAdapter("select Student_Name, Father_Name from Admission where Admission_ID '" + comboBox1.SelectedValue + " '", con);
dt = new DataTable();
DataTable studentdatabase = new DataTable();
da.Fill(studentdatabase);
dataGridView1.DataSource = new BindingSource(studentdatabase, null);
con.Close();
}
else
{
MessageBox.Show("Select an Batch No");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
    
 
 but following error
 
Incorrect syntax near 'hghgh '.
hghgh is my Admission_ID. 
 
 
 
 
 

Answers (5)