How to display error message when record not found in vb.net

独自空忆成欢 提交于 2020-01-07 06:32:47

问题


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.


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/38344186/how-to-display-error-message-when-record-not-found-in-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!