Showing posts with label public. Show all posts
Showing posts with label public. Show all posts

Saturday, March 31, 2012

System.IndexOutOfRangeException

I have the following code...

Public Sub SelectPieceByProductID()

Try

Dim arParams(0) As SqlParameter

arParams(0) = New SqlParameter("@dotnet.itags.org.lProductID", lProductID)

Dim oDR As SqlDataReader =
oData.ExecuteReader(sConnectionString, CommandType.StoredProcedure,
"spSelectPieceByProductID", arParams)

If oDR.HasRows Then
Do While oDR.Read()
sPieceNumber = CType(oDR.Item("PieceNumber"),
String)
lMetalID = CType(oDR.Item("MetalID"), Long)
lTotalCount = CType(oDR.Item("TotalCount"), Long)
dTotalWeight = CType(oDR.Item("TotalWeight"),
Double)
--> lNonCenterCount =
CType(oDR.Item("NonCenterCount "), Long)
dNonCenterWeight =
CType(oDR.Item("NonCenterWeight"), Double)
dPrice = CType(oDR.Item("Price"), Double)
lMarkup = CType(oDR.Item("Markup"), Long)
bActive = CType(oDR.Item("Active"), Boolean)
bDeleted = CType(oDR.Item("Deleted"), Boolean)
Loop
End If

oDR.Close()

oDR = Nothing
oData = Nothing

Catch ex As Exception

End Try

End Sub

I am getting an "System.IndexOutOfRangeException" exception on the
marked line. All values prior to this line are being set correctly.
Anyone see the issue here? I run the query in query analyzer with the
appropriate id and it works fine.

I'm clueless.

Thanks.It seems that the NonCenterCount column does not exist. Perhaps the column
name is mispelled either here, or in the table definition.

"Ratman" <jake@.attis.org> wrote in message
news:df331d52.0406210944.2c966e3c@.posting.google.c om...
> I have the following code...
> Public Sub SelectPieceByProductID()
> Try
> Dim arParams(0) As SqlParameter
> arParams(0) = New SqlParameter("@.lProductID", lProductID)
> Dim oDR As SqlDataReader =
> oData.ExecuteReader(sConnectionString, CommandType.StoredProcedure,
> "spSelectPieceByProductID", arParams)
> If oDR.HasRows Then
> Do While oDR.Read()
> sPieceNumber = CType(oDR.Item("PieceNumber"),
> String)
> lMetalID = CType(oDR.Item("MetalID"), Long)
> lTotalCount = CType(oDR.Item("TotalCount"), Long)
> dTotalWeight = CType(oDR.Item("TotalWeight"),
> Double)
> --> lNonCenterCount =
> CType(oDR.Item("NonCenterCount "), Long)
> dNonCenterWeight =
> CType(oDR.Item("NonCenterWeight"), Double)
> dPrice = CType(oDR.Item("Price"), Double)
> lMarkup = CType(oDR.Item("Markup"), Long)
> bActive = CType(oDR.Item("Active"), Boolean)
> bDeleted = CType(oDR.Item("Deleted"), Boolean)
> Loop
> End If
> oDR.Close()
> oDR = Nothing
> oData = Nothing
> Catch ex As Exception
> End Try
> End Sub
> I am getting an "System.IndexOutOfRangeException" exception on the
> marked line. All values prior to this line are being set correctly.
> Anyone see the issue here? I run the query in query analyzer with the
> appropriate id and it works fine.
> I'm clueless.
> Thanks.

System.IndexOutOfRangeException

I have the following code...
Public Sub SelectPieceByProductID()
Try
Dim arParams(0) As SqlParameter
arParams(0) = New SqlParameter("@dotnet.itags.org.lProductID", lProductID)
Dim oDR As SqlDataReader =
oData.ExecuteReader(sConnectionString, CommandType.StoredProcedure,
"spSelectPieceByProductID", arParams)
If oDR.HasRows Then
Do While oDR.Read()
sPieceNumber = CType(oDR.Item("PieceNumber"),
String)
lMetalID = CType(oDR.Item("MetalID"), Long)
lTotalCount = CType(oDR.Item("TotalCount"), Long)
dTotalWeight = CType(oDR.Item("TotalWeight"),
Double)
--> lNonCenterCount =
CType(oDR.Item("NonCenterCount "), Long)
dNonCenterWeight =
CType(oDR.Item("NonCenterWeight"), Double)
dPrice = CType(oDR.Item("Price"), Double)
lMarkup = CType(oDR.Item("Markup"), Long)
bActive = CType(oDR.Item("Active"), Boolean)
bDeleted = CType(oDR.Item("Deleted"), Boolean)
Loop
End If
oDR.Close()
oDR = Nothing
oData = Nothing
Catch ex As Exception
End Try
End Sub
I am getting an "System.IndexOutOfRangeException" exception on the
marked line. All values prior to this line are being set correctly.
Anyone see the issue here? I run the query in query analyzer with the
appropriate id and it works fine.
I'm clueless.
Thanks.It seems that the NonCenterCount column does not exist. Perhaps the column
name is mispelled either here, or in the table definition.
"Ratman" <jake@.attis.org> wrote in message
news:df331d52.0406210944.2c966e3c@.posting.google.com...
> I have the following code...
> Public Sub SelectPieceByProductID()
> Try
> Dim arParams(0) As SqlParameter
> arParams(0) = New SqlParameter("@.lProductID", lProductID)
> Dim oDR As SqlDataReader =
> oData.ExecuteReader(sConnectionString, CommandType.StoredProcedure,
> "spSelectPieceByProductID", arParams)
> If oDR.HasRows Then
> Do While oDR.Read()
> sPieceNumber = CType(oDR.Item("PieceNumber"),
> String)
> lMetalID = CType(oDR.Item("MetalID"), Long)
> lTotalCount = CType(oDR.Item("TotalCount"), Long)
> dTotalWeight = CType(oDR.Item("TotalWeight"),
> Double)
> --> lNonCenterCount =
> CType(oDR.Item("NonCenterCount "), Long)
> dNonCenterWeight =
> CType(oDR.Item("NonCenterWeight"), Double)
> dPrice = CType(oDR.Item("Price"), Double)
> lMarkup = CType(oDR.Item("Markup"), Long)
> bActive = CType(oDR.Item("Active"), Boolean)
> bDeleted = CType(oDR.Item("Deleted"), Boolean)
> Loop
> End If
> oDR.Close()
> oDR = Nothing
> oData = Nothing
> Catch ex As Exception
> End Try
> End Sub
> I am getting an "System.IndexOutOfRangeException" exception on the
> marked line. All values prior to this line are being set correctly.
> Anyone see the issue here? I run the query in query analyzer with the
> appropriate id and it works fine.
> I'm clueless.
> Thanks.

Saturday, March 24, 2012

system.net.socket question

I have the following code

Public Sub StartListening()
' Data buffer for incoming data.
Dim bytes() As Byte = New [Byte](128000) {}

' Establish the local endpoint for the socket.
Dim ipHostInfo As IPHostEntry = Dns.Resolve(Dns.GetHostName())
Dim ipAddress As IPAddress = ipHostInfo.AddressList(0)
Dim localEndPoint As New IPEndPoint(ipAddress, XXXXX)

' Intializes a TCP/IP socket.
Dim listener As New Socket(AddressFamily.InterNetwork, _
SocketType.Stream, ProtocolType.Tcp)

' Bind the socket to the local endpoint and listen for incoming
' connections.
Try
listener.Bind(localEndPoint)
listener.Listen(100)

While True
' Set the event to nonsignaled state.
allDone.Reset()

' Start an asynchronous socket to listen for connections.
listener.BeginAccept(New AsyncCallback(AddressOf AcceptCallback), _
listener)

' Wait until a connection is made before continuing.
allDone.WaitOne()
End While
Catch e As Exception
'Print out error message to log file
' Console.WriteLine(e.ToString()) '************
End Try
End Sub

Private Sub AcceptCallback(ByVal ar As IAsyncResult)
' Signal the main thread to continue.
allDone.Set()

' Get the socket that handles the client request.
Dim listener As Socket = CType(ar.AsyncState, Socket)
Dim handler As Socket = listener.EndAccept(ar)

' Create the state object.
Dim state As New StateObject
state.xSocket = handler
handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, _
New AsyncCallback(AddressOf readCallback), state)

End Sub

how do I get the IP address from the clients that connect to my sever?nevermind...i figured it out

Trey