Actually i do not think that is the coding problem cause i wrote the coding in a class. i have try to call this function in other form and it worked well. I also checked the parameter passed in. Can u let me know what are the posibility occur this error. i use debug mode to see the code, when it executed to the oConn.Open() it jump to the exception and show the error message. Anyway this is the coding
Public Function GetFromOledbToDataSet(ByVal sCommand As String) As DataSet
Dim oConn As New ADODB.Connection
oConn.ConnectionString = sConnectionString
oConn.CursorLocation = ADODB.CursorLocationEnum.adUseClient
Dim oResultRecordset As New ADODB.Recordset
Try
oConn.CommandTimeout = 10
oConn.Open()
oResultRecordset.ActiveConnection = oConn
oResultRecordset.MaxRecords = MaxNoOfRecord
oResultRecordset.CursorType = ADODB.CursorTypeEnum.adOpenStatic
oResultRecordset.Open(sCommand)
Dim oDataSet As New DataSet
Dim oOledbDataAdapter As New OleDbDataAdapter
oOledbDataAdapter.Fill(oDataSet, oResultRecordset, "FNDOCUMENT")
oConn.Close()
Return oDataSet
Catch ex As Exception
System.Diagnostics.Debug.WriteLine(ex.Message)
Return Nothing
Finally
If Not oConn Is Nothing Then
If oConn.State = ConnectionState.Open Then
oConn.Close()
End If
End If
End Try
End Function