How to display error message when record not found

2019-09-08 18:22发布

I created code for converting binary data to pdf my aim is to show error message when date is not avalable in sql otherwise it should pdf file can anyone help me how to do.

2条回答
【Aperson】
2楼-- · 2019-09-08 18:56

You might wanna try this

Dim csname1 As String = "PopupScript"
Dim csname2 As String = "ButtonClickScript"
Dim cstype As Type = Me.GetType()

Dim cs As ClientScriptManager = Page.ClientScript

If (Not cs.IsStartupScriptRegistered(cstype, csname1)) Then

  Dim cstext1 As String = "alert('Record not found');"
  cs.RegisterStartupScript(cstype, csname1, cstext1, True)

End If

You can also use the approach given here http://docs.telerik.com/devtools/aspnet-ajax/controls/window/troubleshooting/executing-javascript-code-from-server

As you can see it will load the script, you either can load that script or can create a function and call it like VB example in telerik or Mix both approaches to suit you.

查看更多
Bombasti
3楼-- · 2019-09-08 19:01

If you want to show the message on pdf itself then

Using sdr As SqlDataReader = cmd.ExecuteReader()
  if sdr.hasrows then
    sdr.Read()
    pdf = DirectCast(sdr("BinaryData"), Byte())
    ID = sdr("RunId").ToString()
  else 
    pdf = DirectCast("No Data Found", Byte())
  end if
查看更多
登录 后发表回答