locked
Unhandled sqlException error - Could not find stored procedure 'False'. RRS feed

  • Question

  • I recieved the following error when attempting to filter data from an sql server data source in vb.net:

    Could not find stored procedure 'False'.

    I have already checked that the server name is correct and checked that i have permission to access it.

    here is the full code:

    m_DataTable.Clear()
            m_DA = New SqlDataAdapter("Select * from members where member_secondname " = TextBox2.Text, m_cn)
            m_DA.Fill(m_DataTable)
            ViewForm.txtFirstName.Text = m_DataTable.Rows(0).Item("member_firstname")
            ViewForm.TxtScndName.Text = m_DataTable.Rows(0).Item("member_secondname")

    any help would be appreciated.

    namso

    Thursday, March 1, 2012 3:38 PM

Answers

  • Hi,

    "Select * from members where member_secondname " = TextBox2.Text is a boolean telling if the first part is what you have in the textbox.

    You likely wanted to do something like :

    "Select * from members where member_secondname='" & TextBox2.Text & "'" but it won't work for example if you have a ' inside TextBox2.Text (you would have to replace ' with '').

    I strongly recommend to use parameterized query : http://www.codinghorror.com/blog/2005/04/give-me-parameterized-sql-or-give-me-death.html


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    • Marked as answer by namso1902 Friday, March 2, 2012 10:56 AM
    • Unmarked as answer by namso1902 Friday, March 2, 2012 10:57 AM
    • Proposed as answer by Allen_MSDN Monday, March 5, 2012 3:12 AM
    • Marked as answer by namso1902 Tuesday, March 6, 2012 4:25 PM
    Thursday, March 1, 2012 6:19 PM
  • Hi namso1902,

    Welcome to MSDN Forum.

    The error is caused by this line "m_DA = New SqlDataAdapter("Select * from members where member_secondname " = TextBox2.Text, m_cn)", please refer to @Patrice's modified code, it can solved the issue. By the way, I agree with @Patrice's suggestion, using parameterized query is more safe.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by namso1902 Tuesday, March 6, 2012 4:25 PM
    Monday, March 5, 2012 3:12 AM

All replies

  • Hi,

    "Select * from members where member_secondname " = TextBox2.Text is a boolean telling if the first part is what you have in the textbox.

    You likely wanted to do something like :

    "Select * from members where member_secondname='" & TextBox2.Text & "'" but it won't work for example if you have a ' inside TextBox2.Text (you would have to replace ' with '').

    I strongly recommend to use parameterized query : http://www.codinghorror.com/blog/2005/04/give-me-parameterized-sql-or-give-me-death.html


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    • Marked as answer by namso1902 Friday, March 2, 2012 10:56 AM
    • Unmarked as answer by namso1902 Friday, March 2, 2012 10:57 AM
    • Proposed as answer by Allen_MSDN Monday, March 5, 2012 3:12 AM
    • Marked as answer by namso1902 Tuesday, March 6, 2012 4:25 PM
    Thursday, March 1, 2012 6:19 PM
  • Hi namso1902,

    Welcome to MSDN Forum.

    The error is caused by this line "m_DA = New SqlDataAdapter("Select * from members where member_secondname " = TextBox2.Text, m_cn)", please refer to @Patrice's modified code, it can solved the issue. By the way, I agree with @Patrice's suggestion, using parameterized query is more safe.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by namso1902 Tuesday, March 6, 2012 4:25 PM
    Monday, March 5, 2012 3:12 AM