hi friends,
please help me in explaining me how to display details of a particular student by
rollnumber(varchar) and display the details in a grid view in c# language
regards
chiranjeevi
Loading


Resmy Ravi74 reputationPosted Jun 22, 2010, 9:58 PM EDT
OleDbDataAdapter ad = new OleDbDataAdapter("select * from tablename where rollno='"+value+"'", con);
DataSet ds = new DataSet();
ad.Fill(ds, "tablename");
if (ds.Tables[0].Rows.Count > 0)
{
dataGridView1.DataSource = ds.Tables[0].DefaultView;
dataGridView1.DataSource = ds;
}
if the answer helps you...reply me...
Resmy Ravi74 reputationPosted Jun 22, 2010, 9:52 PM EDT
use this query..
select * from student where rollno='"+textbox1.text+"'
Chiranjeevi Aripaka105 reputationPosted Jun 22, 2010, 11:11 PM EDT
hi frnd,
it is accepting for numbers but when i tried for alphanumeric (04331A1209) it is not accepting..
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'A1209'.
Source Error:
Line 26: //SqlDataAdapter da = new SqlDataAdapter("select * from newstudent where rollno = " + Convert.ToString(TextBox1.Text), con); Line 27: DataSet ds = new DataSet(); Line 28: da.Fill(ds); Line 29: GridView1.DataSource = ds;Resmy Ravi74 reputationPosted Jun 27, 2010, 10:20 PM EDT
sorrry...
the last line is not needed.write only dataGridView1.DataSource = ds.Tables[0].DefaultView; .it willl print...