can't seem to get this while

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bic

    can't seem to get this while

    Hi,

    I am baffled as to why I can't seem to get this while statement to bail out
    when it iterates to an empty row? Thanks.

    While (Not IsNothing(objEx cel.worksheets( h).cells(i, 1)))
    Try
    connection.Open ()
    Dim command As New SqlCommand("sp_ insertClaId",
    connection)
    command.Command Type = CommandType.Sto redProcedure
    command.Paramet ers.Add("@iPubI d", Int(TextBox1.Te xt))
    command.Paramet ers.Add("@sCode ",
    objExcel.worksh eets(h).cells(i , j).Value())
    command.Paramet ers.Add("@sName ",
    objExcel.worksh eets(h).cells(i , j + 1).Value())
    command.Paramet ers.Add("@iCatI dOffset", h - 2)
    command.Execute NonQuery()
    Catch ex As Exception
    MsgBox(ex.Messa ge.ToString())
    Finally
    connection.Clos e()
    End Try
    i = i + 1
    k = k + 1
    End While

    --
    bic
  • Patrice

    #2
    Re: can't seem to get this while

    Try to add .value. It seems to me that you are testing if the cell object
    returned by Excel is nothing instead of its value.

    --
    Patrice

    "bic" <bic@discussion s.microsoft.com > a écrit dans le message de
    news:C55456FB-D323-4AC3-9093-814A2D697490@mi crosoft.com...[color=blue]
    > Hi,
    >
    > I am baffled as to why I can't seem to get this while statement to bail[/color]
    out[color=blue]
    > when it iterates to an empty row? Thanks.
    >
    > While (Not IsNothing(objEx cel.worksheets( h).cells(i, 1)))
    > Try
    > connection.Open ()
    > Dim command As New SqlCommand("sp_ insertClaId",
    > connection)
    > command.Command Type = CommandType.Sto redProcedure
    > command.Paramet ers.Add("@iPubI d", Int(TextBox1.Te xt))
    > command.Paramet ers.Add("@sCode ",
    > objExcel.worksh eets(h).cells(i , j).Value())
    > command.Paramet ers.Add("@sName ",
    > objExcel.worksh eets(h).cells(i , j + 1).Value())
    > command.Paramet ers.Add("@iCatI dOffset", h - 2)
    > command.Execute NonQuery()
    > Catch ex As Exception
    > MsgBox(ex.Messa ge.ToString())
    > Finally
    > connection.Clos e()
    > End Try
    > i = i + 1
    > k = k + 1
    > End While
    >
    > --
    > bic[/color]


    Comment

    Working...