Sanjeeb Sapkota

Sanjeeb Sapkota

  • 940
  • 832
  • 47.4k

Use Parameteri in OracleDataReader with StringBuilder in VB.

Feb 11 2016 11:24 AM
I have this code for retrive data from my oracle database:
Dim sb As New System.Text.StringBuilder
sb.AppendLine("SELECT * FROM NOULGH")
Using dar As Oracle.DataAccess.Client.OracleDataReader = Ibr.DataReader(sb.ToString)
While dar.Read()
page_no = dar("PRINT_NO").ToString()
page_no1 = dar("PAGE_NO1").ToString()
End While
End Using
Now i want to retrieve the data from Oracle database using parameter.
Private Function createCSVBody(ByVal reader As String)
Try
Dim sb As New System.Text.StringBuilder
sb.AppendLine("SELECT * FROM NOULGB WHERE PRINT_NO=@readerno")
sb.AppendLine(New OracleParameter("@readerno", OracleDbType.Char, reader, ParameterDirection.Input).ToString)
Using dar As Oracle.DataAccess.Client.OracleDataReader = Ibr.DataReader(sb.ToString)
While dar.Read()
page_no = dar("PRINT_NO").ToString()
page_no1 = dar("PAGE_NO1").ToString()
End Using
End Function
But it is not working for me. Can anybody help me?