I have 2 texts boxes "TextBox1" and "TextBox2" and a submit button called "Button1" Below that i have a Label "Label1"
What i need to do is search between dates in "Input1 & Input2" (yyyy-mm-dd) and display a value (It is just counting the records in the tabels)
This is my current query
Dim c As New MySqlConnection("Server=localhost;Database=test;UID=test;PWD=test;")
c.Open()
Dim com As New MySqlCommand("SELECT COUNT(*) as c FROM toutcome WHERE AffID = '0001' AND CompletedDate >= CURDATE();", c)
Dim myReader As MySqlDataReader = com.ExecuteReader(CommandBehavior.CloseConnection)
myReader.Read()
Label1.Text = myReader.Item(0).ToString()
myReader.Close()
And here is the query i am attempting to use to complete the above task, it is not working at all.
Dim c As New MySqlConnection("Server=localhost;Database=mdxmain;UID=MerryWoodTest;PWD=H0r$hamTest;")
c.Open()
Dim com As New MySqlCommand("SELECT COUNT(*) as c FROM toutcome WHERE AffID = '0001' AND WHERE CompletedDate >= '" & TextBox1.Text & "' AND CompletedDate <= '" & TextBox2.Text & "'", c)
Dim myReader As MySqlDataReader = com.ExecuteReader(CommandBehavior.CloseConnection)
myReader.Read()
Label11.Text = myReader.Item(0).ToString()
myReader.Close()
The top Query works and i get a value.
The bottom query error is
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 'WHERE CompletedDate >= '' AND CompletedDate <= ''' at line 1]