Concatenating SQL statements in VB.NET
I am trying to type the SQL query statements in the code for a Order entry application, so that the query will execute at runtime instead of just typing it directly into the data adapter at design time. The runtime SQL worked for integers, but I am having a hard time concatenating the SQL statement properly to search for text. Does anyone happen to know anything about the concatenation for that? I'd greatly appreciate any advice you all could give us. Thanks!
Also, were is the code for a search button that searches a database called customers. In Bold is the problem we are having.
Private Sub frmFinalProject_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
mstrQuery = "SELECT CustNo, CustName, AddrZip, AddrStreet, AddrState, AddrCity FROM Cust "
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim bull**** As String
If txtCustName.Text = "" Then
Else
DsCustomer1.Clear()
dbCustomer.SelectCommand.CommandText = mstrQuery & "WHERE CustName = " & txtCustName.Text
dbCustomer.Fill(DsCustomer1)
End If
txtCustNo.Text = cbocustno.Text
End Sub