Results 1 to 3 of 3

Thread: using parameters in query string [resolved]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2004
    Location
    in the heart of the Mediterranean
    Posts
    1,143

    using parameters in query string [resolved]

    Hi,

    My error states that I should be declaring @checkBook. I am assuming I am declaring it in [RED] so where's the mistake pls???

    Also do I need to use an adapter in here cos I had a search and found this method but I am assuming I need to state my connection somewhere right?? How's that??

    Also if someone knows of any good link where I could learn more about parameters please send me link.

    many thanks


    Code:
    Private Sub CurrentBalanceShowD()
            Dim cmd As New SqlCommand
    
            Try
                cmd.Parameters.AddWithValue("@checkBook", SqlDbType.Int).Value = cboBookD.SelectedValue            cmd.Parameters.AddWithValue("@checkBook", bookFID)
    
    
                MyConn.Open()    'opening the connection
                cmd = New SqlCommand("Select stockBalance from tb_bookbalance where bookFID = @checkBook", MyConn) 'executing the command and assigning it to connection 
    
                txtcurrentD.Text = (cmd.ExecuteScalar()).ToString   'displaying the data from the table
                MyConn.Close()
            Catch ex As Exception
                MsgBox(ex.Message)
                MyConn.Close()
            End Try
        End Sub
    Last edited by angelica; Jun 7th, 2008 at 10:54 AM.

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