누구나 다음 작동하지 않는 이유를 알고 계십니까? 이 asp.net 코드가 작동하지 않습니다
Dim strPhrase As String = "'%office%'"
objStringBuilder = New StringBuilder()
objSQLConnection = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("connString"))
objSQLCommand = New SqlCommand("select col1, col2 from table1 where phrase like @phrase", objSQLConnection)
objSQLCommand.Parameters.Add("@phrase", SqlDbType.VarChar, 255).Value = strPhrase
objSQLCommand.Connection.Open()
objSQLDataReader = objSQLCommand.ExecuteReader()
While objSQLDataReader.Read()
objStringBuilder.Append(objSQLDataReader("col1") & " - " & objSQLDataReader("col2"))
End While
objSQLDataReader.Close()
objSQLCommand.Connection.Close()
return objStringBuilder.tostring()
내가 phrase
와 아무 제거하면
objStringBuilder = New StringBuilder()
objSQLConnection = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("connString"))
objSQLCommand = New SqlCommand("select col1, col2 from table1", objSQLConnection)
objSQLCommand.Connection.Open()
objSQLDataReader = objSQLCommand.ExecuteReader()
While objSQLDataReader.Read()
objStringBuilder.Append(objSQLDataReader("col1") & " - " & objSQLDataReader("col2"))
End While
objSQLDataReader.Close()
objSQLCommand.Connection.Close()
return objStringBuilder.tostring()
내가 오류를 얻을, 그냥 빈 문자열을 반환합니다.
+ 1, Four Figures Club에 오신 것을 환영합니다. D – Town