Hello everyone!
Am trying to retrieve data from sql server based on two columns. Its a web application being developed using VS2010 (vb.net) but i keep getting the error: incorrect syntax near '='
Here's my code below:
Sub GetBasicMidwives()
' Set the SelectCommand properties...
With objDataAdapter
.SelectCommand = New SqlCommand()
.SelectCommand.Connection = objConnection
.SelectCommand.CommandText = "SELECT Reference_Number, Year, Title, Surname," + _
"FirstName, Date_of_Birth, Origin, Phone, State_Deployed, Facility_Deployed FROM HEALTHWORKERS" + _
"WHERE DESIGNATION = BASIC MIDWIVES"
.SelectCommand.CommandType = CommandType.Text
End With
' Open the database connection...
objConnection.Open()
' Fill the DataSet object with data...
objDataAdapter.Fill(objDataSet, "HEALTHWORKERS")
' Close the database connection...
objConnection.Close()
' Set the DataGridView properties to bind it to our data...
With BMGridView
.AutoGenerateColumns = True
.DataSource = objDataSet
.DataMember = "HEALTHWORKERS"
.DataBind()
End With
RecordCountLabel.Text = BMGridView.Rows.Count & " " & "Record(s)"
'clear memory
objDataAdapter = Nothing
objConnection = Nothing
End Sub