Home All Groups Group Topic Archive Search About

to veiw data in datagrid

Author
24 Apr 2007 5:46 AM
lijin
its a vb.net code .....im doing a data base
Show quote
> application.....the datbase is ms sql server...in my
> front end form there is a datagrid where i have
> displayed the details from the database by dragging
> it into a dataset.....after words i have created a
> test box where i enter some selective details from
> the grid and the the entire details is then
> retrieved and then displayed on the data grid...but
> there is a problem ...the selection of data is not
> working and it doest show any error...i m giving the
> code i have created  ...c if u can figure out
> anything
>
> Private Sub txtcid1_TextChanged(ByVal sender As
> System.Object, ByVal e As System.EventArgs) Handles
> txtcid1.TextChanged
>       
>  Dim constr As String = "C:\Documents and
> Settings\rupesh\My Documents\ME.mdf;Integrated
> Security=True;Connect Timeout=30;User Instance=True"
>        
> Dim conn As SqlClient.SqlConnection = New
> SqlClient.SqlConnection(constr)
>
>         Dim sqlstr As String = "SELECT * FROM Course
> WHERE COURSE ID LIKE'" & Trim(txtcid1.Text) & "%'"
>         Dim da As SqlClient.SqlDataAdapter = New
> SqlClient.SqlDataAdapter(sqlstr, conn)
>
>         Dim ds As DataSet = New DataSet
>         da.Fill(ds, "Course")
>         DataGridView1.DataSource =
> ds.DefaultViewManager
>
>     End Sub
>

Author
24 Apr 2007 6:16 AM
Manish Bafna
Hi,
Try this code:
DataGridView1.DataSource = ds.Tables(0)
--
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.



Show quote
"lijin" wrote:

> its a vb.net code .....im doing a data base
> > application.....the datbase is ms sql server...in my
> > front end form there is a datagrid where i have
> > displayed the details from the database by dragging
> > it into a dataset.....after words i have created a
> > test box where i enter some selective details from
> > the grid and the the entire details is then
> > retrieved and then displayed on the data grid...but
> > there is a problem ...the selection of data is not
> > working and it doest show any error...i m giving the
> > code i have created  ...c if u can figure out
> > anything
> >
> > Private Sub txtcid1_TextChanged(ByVal sender As
> > System.Object, ByVal e As System.EventArgs) Handles
> > txtcid1.TextChanged
> >       
> >  Dim constr As String = "C:\Documents and
> > Settings\rupesh\My Documents\ME.mdf;Integrated
> > Security=True;Connect Timeout=30;User Instance=True"
> >        
> > Dim conn As SqlClient.SqlConnection = New
> > SqlClient.SqlConnection(constr)
> >
> >         Dim sqlstr As String = "SELECT * FROM Course
> > WHERE COURSE ID LIKE'" & Trim(txtcid1.Text) & "%'"
> >         Dim da As SqlClient.SqlDataAdapter = New
> > SqlClient.SqlDataAdapter(sqlstr, conn)
> >
> >         Dim ds As DataSet = New DataSet
> >         da.Fill(ds, "Course")
> >         DataGridView1.DataSource =
> > ds.DefaultViewManager
> >
> >     End Sub
> >

AddThis Social Bookmark Button