简体   繁体   中英

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

我创建了将二进制数据转换为pdf的代码,目的是在sql中没有可用日期时显示错误消息,否则pdf文件应该有人可以帮助我怎么做。

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM