Our department moved from MS System.Data.OracleClient to ODP and I
wondering how do I fill a DataSet object? I am new to VB.NET so I am
learning as I go. I've added the new ODP reference to the application
and have changed any reference to System.Data.OracleClient to
Oracle.DataAccess.Client. In the application that I have inherited,
there is a function that gets a record set and populates an array,
though when I use this function, I receive an error when trying to
fill the DataAdapter with the DataSet(Attempted to read or write
protected memory. This is often an indication that other memory is
corrupt.). The DataSet is empty which is causing the error. Can some
one please tell me what I should be using instead?
Thanks for your help,
William.
Noted below is the code for the function:
Public Shared Function PopulateRS(ByVal SQL As String) As String()
'ching created
Dim rsArray(0 To -1) As String
Dim i As Integer = 0
Dim ds3 As System.Data.DataSet = New System.Data.DataSet
Dim conn As Oracle.DataAccess.Client.OracleConnection = Nothing
Dim da3 As Oracle.DataAccess.Client.OracleDataAdapter = Nothing
Try
BasePage.OpenConnection(conn)
da3 = New Oracle.DataAccess.Client.OracleDataAdapter(SQL,
conn)
da3.Fill(ds3)
If ds3.Tables(0).Rows.Count > 0 Then
ReDim Preserve rsArray(ds3.Tables(0).Rows.Count) 'Declare
space again
For Each dr As System.Data.DataRow In ds3.Tables(0).Rows
rsArray(i) = CStr(dr(0).ToString)
'Check if it is the last row
If i < ds3.Tables(0).Rows.Count Then
i = i + 1
Else
Exit For
End If
Next
End If
Catch ex As Exception
BasePage.CloseConnection(conn)
da3.Dispose()
ds3.Dispose()
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.Redirect("e_m.aspx?lang=" &
System.Web.HttpContext.Current.Session("lang") & "&err=" &
HttpContext.Current.Server.UrlEncode(ex.Message))
End Try
BasePage.CloseConnection(conn)
da3.Dispose()
ds3.Dispose()
PopulateRS = rsArray
End Function
--
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net