can't seem to get this while

G

Guest

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(objExcel.worksheets(h).cells(i, 1)))
Try
connection.Open()
Dim command As New SqlCommand("sp_insertClaId",
connection)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add("@iPubId", Int(TextBox1.Text))
command.Parameters.Add("@sCode",
objExcel.worksheets(h).cells(i, j).Value())
command.Parameters.Add("@sName",
objExcel.worksheets(h).cells(i, j + 1).Value())
command.Parameters.Add("@iCatIdOffset", h - 2)
command.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message.ToString())
Finally
connection.Close()
End Try
i = i + 1
k = k + 1
End While
 
P

Patrice

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top