Results 1 to 3 of 3

Thread: please help! - find rows and check, URGENT!! :(

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    128

    Thumbs down please help! - find rows and check, URGENT!! :(

    i have four text boxes, a user enters four three figure numbers into these boxes, i then conbine them into on value, adding .'s between each value:

    tx1 tx2 tx3 tx4
    | | | |
    txtAll = 194.003.003.003

    i want to look into the dataset and read the table held on the sql server, then check to see if the field "IPAddress" in any row matches the "txtAll" and if there is display a message otherwise input the data into the table.

    my code is:

    Code:
    Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
      txtAll.Value = (tx1.Value & "." & tx2.Value & "." & tx3.Value & "." & tx4.Value)
      Dim SQLchkIP As String = "(IPAddress = '" & textAll.Value & "')"
      Dim fndRows As DataRow() = dstSSDNetworkHardwareList.Tables("tblNetworkHardware").Select(SQLchkIP)
      If fndRows.Length <= 0 Then
        lblMessage.Text = "OK!"
      Else
        lblMessage.Text = "Already in use!"
      End If
    End Sub
    at the moment there are 5 rows in the table, but even if i use the line:

    [CODE[Dim fndRows As DataRow() = dstSSDNetworkHardwareList.Tables("tblNetworkHardware").Select[/CODE]
    i.e select all, it still return the value of 0 into fndRows..!!!!

    please help.
    Tom
    Last edited by tmashley; Oct 24th, 2002 at 09:52 AM.

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    I see some strange things in your code:
    First maybe I am wrong, but to my knowledge 'String' does not have a member 'value', so if tx1,... are strings then what is tx1.Value? correct me if i am wrong.
    I would have done that like this

    ----------------------------------------------------------------------------
    srch = Val(TextBox1.Text).ToString("000") & "." & Val(TextBox2.Text).ToString("000") & "." & _
    Val(TextBox3.Text).ToString("000") & "." & Val(TextBox4.Text).ToString("000")
    srch="IPAddress= '" & srch & "'"
    ----------------------------------------------------------------------------

    second:
    There are improper uses of "(" in your code, it may not cause problem i guess, but it would better be like this:

    Dim SQLchkIP As String = "IPAddress = '" & textAll & "'"

    and
    .....Tables("tblNetworkHardware").Select()[/CODE]


    Afterall and most important:
    Have you filled your dataset using your sqldataadapter??

    I have included a sample using oledbdatadapter, the concept should be basically the same as sqldbdataadapter. Try it!
    Attached Files Attached Files

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    128
    i have fixed it by changing the txtAll into a string from a textbox, Thanks for your help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width