| |

VerySource

 Forgot password?
 Register
Search
Author: 板砖飞校长

How can I find out if a variable has a value?

[Copy link]

0

Threads

73

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-4-24 00:45:01
| Show all posts
Then you always have the definition and assignment of theTitle, set a breakpoint at that assignment
Reply

Use magic Report

4

Threads

11

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

 Author| Post time: 2020-4-25 12:00:01
| Show all posts
I defined it in <script> </ script>:

<asp: Content ID = "Content1" ContentPlaceHolderID = "ContentPlaceHolder1" Runat = "Server">

  <script Runat = "Server">
      Dim theTitle As String
      Dim theContent As String
      Dim theAuthor As String
      Dim theCopyFrom As String
      Dim theAddTime As String
      Sub page_load (ByVal Sender As Object, ByVal E As EventArgs)
          

          Dim Cnn As SqlConnection
          Dim Cmd As SqlCommand
          Dim DataR As SqlDataReader
          Dim StrCnn As String
         
          Dim codestr As String = Request.QueryString ("id")
          Dim sql As String
          If Trim (codestr) <> "" Then
              StrCnn = "server = localhost; uid = as; pwd =; database = myweb"
              Cnn = New SqlConnection (StrCnn)
              Cnn.Open ()
              sql = "select * from book_info where id ="&Trim (codestr)
              Cmd = New SqlCommand (sql, Cnn)
              DataR = Cmd.ExecuteReader
              If DataR.Read () Then
                  theTitle = DataR ("title")
                  theContent = DataR ("content")
                  theAuthor = DataR ("author")
                  theCopyFrom = DataR ("copyfrom")
                  theAddTime = DataR ("addtime")
              Else
                  Cnn.Close ()
                  Response.Write ("<font color = 'gray'> Please select an article! </ Font>")
                  Response.End ()
              End If
              Cnn.Close ()
          End If
      End Sub
</ script>
----
I set a breakpoint, but page_load is not executed, why?
Reply

Use magic Report

0

Threads

73

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-5-23 14:30:01
| Show all posts
Try to change to the following:

If Trim (codestr) <> "" Then
    StrCnn = "server = localhost; uid = as; pwd =; database = myweb"
    Cnn = New SqlConnection (StrCnn)
    Cnn.Open ()
    sql = "select * from book_info where id ="&Trim (codestr)
    Cmd = New SqlCommand (sql, Cnn)
    DataR = Cmd.ExecuteReader
    If DataR.Read () Then
        theTitle = DataR ("title")
  Response.Write ("TheTitle sets the value")
  Response.End ()
        theContent = DataR ("content")
        theAuthor = DataR ("author")
        theCopyFrom = DataR ("copyfrom")
        theAddTime = DataR ("addtime")
    Else
  Response.Write ("theTitle has no set value")
  Response.End ()
        Cnn.Close ()
        Response.Write ("<font color = 'gray'> Please select an article! </ Font>")
        Response.End ()
    End If
    Cnn.Close ()
Else
  Response.Write ("theTitle has no set value")
  Response.End ()
End If
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list