2017年12月11日 星期一

dd

 Public Shared Function getattachment(ByVal no As String) As Integer
        Dim conString As String = "Server=192.168.0.208;Port=5432; Userid=confluence_user;Password=confluence_user; Protocol=3;SSL=false;Pooling=true;Mi" &
      "nPoolSize=1; MaxPoolSize=20;Encoding=UNICODE; Timeout=15;SslMode=Disable;Database=confluence2"
        Dim ourDataTable1 As DataTable = Nothing
        Dim connection As Npgsql.NpgsqlConnection = New Npgsql.NpgsqlConnection(conString)
        Try
            'MsgBox(no)
            ourDataTable1 = New DataTable
            Dim ourAdapter1 As Npgsql.NpgsqlDataAdapter = New NpgsqlDataAdapter("select sdata1-sdata2 as rlt " &
    "from " &
    "( " &
        "select id3, sum(data1) as sdata1, sum(data2) as sdata2 " &
        "from " &
        " ( " &
            "select b.spacekey as id3,count(1) as data1, 0 as data2 " &
            "from content a,spaces b " &
            "where a.spaceid = b.spaceid  " &
               " and a.contenttype = 'PAGE' " &
                "and a.content_status = 'current' " &
                "and a.prevver is null and b.spacekey='" & no & "'" &
            " group by b.spacekey " &
            "union all " &
            "select id3, 0 as data1, id6 as data2 " &
            "from log2 where id2='7' and id3='" & no & "'" &
        ") v1 " &
       " group by id3 " &
    ") v2 ", connection)


            'CAST (id3 AS INTEGER)
            ' MsgBox("SELECT (t2.data - t1.data) AS data FROM log2 AS t1 INNER JOIN content AS t2 ON t1.id = t2.id WHERE t1.CAST (id3 AS INTEGER) =" & no & "")
            ourAdapter1.SelectCommand.Parameters.AddWithValue("@no", no)
            ' ourAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
            ourAdapter1.Fill(ourDataTable1)
            If IsDBNull(no) Then
                Return ""
            Else
                If ourDataTable1.Rows.Count <> 0 Then
                    Return ourDataTable1.Rows(0)("rlt").ToString
                Else
                    Return ""
                End If
            End If

        Catch ex As Exception

        End Try


    End Function

沒有留言:

張貼留言