Quantcast
Channel: Adobe Community : Discussion List - Using Flash Builder
Viewing all articles
Browse latest Browse all 1802

Flex get number value from asp.net always get 0

$
0
0

Dear all,

In my project I have:

(1) one function in asp.net, which get the number of records from database.

(2) flex widget which pass the query string to asp.net web service and get the number of records from the query string.

The situation is:

I use the same query statement : "select count(*) as cnt from CUSTOMERS where CUSTOMER_NAME = 'Angela Tang'"

I can get the correct result from asp.net itself.

enter image description here

result:

<?xml version="1.0" encoding="UTF-8"?>

<intxmlns="http://tempuri.org/">2</int>

The code in flex is as follows:

var countSql:String="select count(*) as cnt from CUSTOMERS WHERE CUSTOMER_NAME = 'Angela Tang'";

var totalCount:int= ws.GetTotalCount(countSql);

Alert.show("final count = "+ totalCount.toString());

 

The getTotalCount method in asp.net is as follows:

 

<WebMethod> _
Public Function GetTotalCount(ByVal sqlQuery As String) As Integer

  Dim count As Integer

  Try
  conn.Open()
  If Not sqlQuery = Nothing Then
  cmd = New SqlCommand(sqlQuery, conn)
  reader = cmd.ExecuteReader()
  If reader.Read() Then
  count = reader("cnt")
  End If
  reader.Close()
  End If

  conn.Close()
  Catch ex As Exception
  Throw New ApplicationException("Error in collecting data from Database. Error is :" & ex.Message)
  End Try

  Return count
End Function

 

BUT in flex, I always get the totalCount value as 0.

I cannot figure out what is wrong, any idea on it? thanks a lot.


Viewing all articles
Browse latest Browse all 1802

Trending Articles