how to insert data into datagridview from sql table using recordset in vb6.0

'On Error GoTo Error_Handler
If rs.State = adStateOpen Then rs.Close
rs.Open "select *" _
& " from [tablename] " _
, db, adOpenDynamic, adLockReadOnly
DataGrid1.ColWidth(0) = 1000
Set DataGrid1.DataSource = rs
Exit_Error_Handler:
Set rs = Nothing
Exit Sub
Error_Handler:
MsgBox Err.Number & " : " & Err.Description
Resume Exit_Error_Handler

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.