AnsweredAssumed Answered

Retrieving SQL Data from EPDM API

Question asked by Kent Keller on Sep 9, 2011
Latest reply on Sep 14, 2011 by Wayne Matus

I have had several occations where I needed to retreive simple information from the SQL database using SQL.  I do not find any API that returns the database connection string or allows execution of SQL query.


Now, I know this is "Dangerous", but it is also very powerful. 


I have functions in my API that do this, but they are very restricted to a known connection string.


    Public Function GetNextRevision(ThisFile As IEdmFile5)

        Dim strFileName As String = ThisFile.Name

        Dim da As New SqlClient.SqlDataAdapter
        Dim cn As New SqlClient.SqlConnection
        cn.ConnectionString = strConnectionString
        If cn.State = 0 Then
        End If
        Dim strSQL As String = "Select * from documents where ..."

        Dim cmdSQL As New SqlClient.SqlCommand
        cmdSQL.CommandText = strSQL
        Dim ds As New System.Data.DataSet
        cmdSQL.Connection = cn
        da.SelectCommand = cmdSQL
        da.Fill(ds, "Documents")
        If ds.Tables("Documents").Rows.Count > 0 Then
            Return ds.Tables("Documents").Rows(0)("NextRevision").ToString
            Exit Function
        End If
        Return 0
    End Function


Any thoughts on this?