Dear freinds i want to get specific data in gridview specifc cell with the help of sql query from sql table

i put the following query but it doesn't work

Sql = "select e.item_no from nitmtbl e,purchaseitem g where e.item_name=g.item_name and g.item_name='grovita sp'"
        Da = New SqlDataAdapter(Sql, Class1.Connection)
        Da.SelectCommand.ExecuteNonQuery()
        Dim ds As New DataSet
        Da.Fill(ds, "nitmtbl")
        DataGridView1.Rows(0).Cells(0).Value = ds.Tables("nitmtbl")

kindly help me

Recommended Answers

All 2 Replies

Sql = "select e.item_no from nitmtbl e,purchaseitem g where e.item_name=g.item_name and g.item_name='grovita sp'"

Da = New SqlDataAdapter(Sql, Class1.Connection)

Dim dt As New DataTable
Da.Fill(dt)
DataGridView1.DataSource=dt

yr this query give error in DT

error is: Variable "dt"is used before it has assigned a null value

and 1 more thing i want to explain i want that vakue come from table in a way that when i make any entry in datagrid view and when i put a item name in datagrid 2 cell the 1st cell value come automatically with the help of above query query

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.