hello,
Im using VB6 and have connected my datagid OLE to a table in Oracle using adodb, the code seems clean but it doesn't display the table. PID is a patient ID variable.
Here's the code:

Dim oconn As New ADODB.Connection
Dim rsView As New ADODB.Recordset
Dim strSqlView As String

Set oconn = New ADODB.Connection
oconn.Open "Provider=MSDAORA.1;Password=tiger;User ID=scott;Data Source=work;Persist Security Info=True"
oconn.CursorLocation = adUseClient

Set datagrid_view.DataSource = Nothing

strSqlView = "Select previous_casehistory.date_of_visit, previous_casehistory.doctor, previous_casehistory.dept, "
strSqlView = strSqlView + "previous_casehistory.ailment, previous_casehistory.drug_prescribed"
strSqlView = strSqlView + " from previous_casehistory where previous_casehistory.patient_id =" + "'" + PID + "'"

rsView.Open strSqlView, oconn, adOpenStatic, adLockOptimistic, adCmdText

If (rsView.EOF = False) Then
Set datagrid_view.DataSource = rsView
End If
rsView.Close

By debugging I know that the recordset is not empty. I have tried replacing the string query with a simpler query but that is not displayed either. Am I missing something?? Please help.

Remove the line
rsView.Close

And report whether it works or not
Good Luck

Should have replied earlier, thank you! Works fine now..

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.