Question: I want to display data from database in DataGridView...This is my code...Its not working...Can anyone help me wat to do......

```
    Dim DBCONSRT, QRYSTR As String
    Dim strSQL, skunbr As String
    Dim DBCON, myConn, myCommand, rs As Object
    Dim NoOfRecords As Long
    skunbr = TextBox1.Text
    rs = CreateObject("ADODB.Recordset")
    Const DB_CONNECT_STRING = "Provider=MSDASQL.1;Persist Security Info=False;User ID=cpa5k;Data Source=NP1;DSN=NP1;UID=user;PASSWORD=pass;SDSN=Default;HST=ibslnpb1.sysplex.homedepot.com;PRT=4101;Initial Catalog=QA1MM;"
    myConn = CreateObject("ADODB.Connection")
    myCommand = CreateObject("ADODB.Command")
    myConn.Open(DB_CONNECT_STRING)
    myCommand.ActiveConnection = myConn
    myCommand.CommandText = "update QA1MM.STRSK_OH set OH_QTY = 250 where SKU_NBR = 100013 and STR_NBR = 116;"
    myCommand.Execute()
    strSQL = "select * from QA1MM.STRSK_OH where SKU_NBR =  " & skunbr & "  with ur FETCH FIRST 10 ROWS ONLY;"
    rs.Open(strSQL, myConn)
    DataGridView1.DataSource = rs
    DataGridView1.Refresh()
    myConn.Close()

```

Answer: 
Instead of assigning a [`ADODB.RecordSet`](http://msdn.microsoft.com/en-us/library/aa720078%28v=vs.71%29.aspx) directly to the datasource of datagridview like that, first convert/fill the recordset values to a dataset like below

```
Dim myDA As OleDbDataAdapter = New OleDbDataAdapter
Dim myDS As DataSet = New DataSet

myDA.Fill(myDS, rs, "MyTable")
DataGridView1.DataSource = myDS.Tables(0)     
DataGridView1.Refresh() 

```
This is the classic VB way. Not .net

Please refer this [MSDN](http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/gridview.aspx) link