Hi,
im very new at this whole programming thing, and Im writing a page
which has a search function. the click event of the submit button runs
the sub which follows. Its supposed to search the part number entered
by the user from my mysql database. But everytime I try it,
ExecuteReader causes an error.
Sub Submit_Search(ByVal obj As System.Object, ByVal e As
System.EventArgs) Handles btn_submit.Click
'This function gets the part number entered by the user and finds it
in the database, and returns the data for this part number.
'Link to database
Dim myConnection As New MySqlConnection("server=localhost; user
id=myuser; database=database1; pooling=false;")
myConnection.Open()
'Find the matching part number
Dim strSearch
strSearch = "SELECT part_no, cust_part_no, customer FROM table1
WHERE part_no=" & search_part_no.Text & ";"
Dim sqlComm_search As New MySqlCommand(strSearch, myConnection)
Dim sqlRead As MySqlDataReader = sqlComm_search.ExecuteReader()
'sqlRead.Read()
'Display the row of data
myConnection.Close
end sub
And here is the error message that I get:
Server Error in '/' Application.
--------------------------------------------------------------------------------
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near '' at line 1
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: MySql.Data.MySqlClient.MySqlException: You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near '' at line 1
Does anyone have any idea why this is happening? I know the connection
has to be open, but i thought i already opened it. One thing to note,
in my page_load sub, i also connect to and read data from my mysql
database. But does this matter?
Thanks in advance!
Helvin