Re: count(*) error

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



What is the data type of result when you step it through the debugger?

--
Ginny


"WDS" <jbarco@xxxxxxxxxx> wrote in message news:%23qR$t0dqHHA.1296@xxxxxxxxxxxxxxxxxxxxxxx
Here is the code: The system crashes when I assign to the variable ContTotalPallet the value of the result
ContTotalPallet = rs.Item(2).ToString
ContTotalScaned = rs1.Item(1).ToString


Private Function validate_container(ByVal container As String) As Boolean
Dim conn As New SqlCeConnection
Dim cmd As New SqlCeCommand
Dim rs As SqlCeResultSet

validate_container = False
conn.ConnectionString = localhost
conn.Open()
cmd.Connection = conn
cmd.CommandText = "SELECT a.container, a.status, count(b.pallet) "
cmd.CommandText += "FROM contmast a, contdet b "
cmd.CommandText += " where a.container = '" + container + "' and a.container = b.container "
cmd.CommandText += " group by a.container, a.status "

rs = cmd.ExecuteResultSet(ResultSetOptions.Scrollable)
If rs.HasRows = False Then
MessageBox.Show("Container does not exist.", "NCLDOCKSIDE")
Exit Function
Else
rs.Read()
ContTotalPallet = rs.Item(2).ToString

cmd.CommandText = "SELECT a.container, count(b.pallet) "
cmd.CommandText += "FROM contmast a, contdet b "
cmd.CommandText += " where a.container = '" + container + "' and a.container = b.container "
cmd.CommandText += " and b.userscaned <> '' "
cmd.CommandText += " group by a.container "

Dim rs1 As SqlCeResultSet
rs1 = cmd.ExecuteResultSet(ResultSetOptions.Scrollable)
rs1.Read()
ContTotalScaned = rs1.Item(1).ToString

If ContTotalScaned = ContTotalPallet Then
MessageBox.Show("All pallets were scanned.", "NCLDOCKSIDE")
Exit Function
End If
display_container()
display_scanned()
End If
validate_container = True
End Function

"dbgrick" <dbgrick@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:A2AEDE78-2C6D-45FE-A766-A8597ECE175C@xxxxxxxxxxxxxxxx
Could you provide your example code. If we saw what you were doing, we might
be able to figure out what is causing the unhandled exception.

Rick D.
Contractor

"WDS" wrote:

Hello I have a mobile application on Visual Studio .Net 2005. I need to make
a select count(*) for counting how many records scanned for a specific login
field. The strange thing is the program crashes right when I get the value
of the select and assigng it to a variable. Do you know why that happens? Is
count(*) not supported on SQLCE? Do you have an example of doing a select
count(*) and returning a value because probably it's crashing when assigning
to the variable.

Thanks for your help
Jennyferd






.



Relevant Pages

  • Re: count(*) error
    ... you should check if the read was successful. ... The read method returns a boolean indicating if the read was successful. ... ContTotalPallet the value of the result ... Dim conn As New SqlCeConnection ...
    (microsoft.public.sqlserver.ce)
  • Re: count(*) error
    ... The system crashes when I assign to the variable ... ContTotalPallet the value of the result ... Dim conn As New SqlCeConnection ... of the select and assigng it to a variable. ...
    (microsoft.public.sqlserver.ce)