代码运行但没有输出,我的错误是什么?

时间:2016-06-28 06:28:13

标签: mysql vb.net

 Protected Sub View_click(ByVal sender As Object, ByVal e As EventArgs)
        Dim id As Integer = Integer.Parse(TryCast(sender, LinkButton).CommandArgument)
        Dim lsfilename As String
        Dim lsfilepath As String
        Dim savePath As String = "c:/Users/Administrator.VCIDEX3/Downloads"

        Dim embed As String = "<object data=""{0}"" type=""application/pdf"" align=""center"" width=""500px"" height=""600px"">"
        embed += "</object>"
        objdbconn.OpenConn()
        msSQL = "select Id,FileName,FilePath from tblfiles where Id='" & id & "'"
        objODBCDataReader = objdbconn.GetDataReader(msSQL)
        If objODBCDataReader.HasRows = True Then
            objODBCDataReader.Read()
            lsfilename = objODBCDataReader.Item("FileName").ToString
            lsfilepath = objODBCDataReader.Item("FilePath").ToString
        End If
        msSQL = " select * from tblfiles where id='" & id & "'  "
        ltEmbed.Text = String.Format(embed, ResolveUrl("'" & savePath & "' /q.pdf"))
        objdbconn.CloseConn()
    End Sub




<asp:Literal ID="ltEmbed" runat="server" />
  

这里我尝试使用文字查看PDF文件,代码执行和我   正确得到c:/Users/Administrator.VCIDEX3/Downloads/q.pdf但是   文件未显示。

1 个答案:

答案 0 :(得分:1)

您的文字中有两个参数占位符,即{0}和{1},但您只提供一个值,即ResolveUrl的结果。如果文本期望要替换两个值,则需要提供两个值。