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 RaviPosted Jun 23, 2010, 1:58 AM
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 RaviPosted Jun 28, 2010, 2:20 AM
sorrry...
the last line is not needed.write only dataGridView1.DataSource = ds.Tables[0].DefaultView; .it willl print...
Chiranjeevi AripakaPosted Jun 23, 2010, 3:11 AM
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 RaviPosted Jun 23, 2010, 1:52 AM
use this query..
select * from student where rollno='"+textbox1.text+"'