my search button already worked but there's one minor problem. it shows
all records and not what i specified to look for. this is my code anyway:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim myquery As New MyClasslibrary.MyHelper
Form3.connect(myquery)
Dim myd As DataTable
With myquery
Dim id As String = ""
myd = .runQuery("SELECT Date, Lastname, Firstname,
ts.Barangay," _
& "`Sitio/Purok`, tc.Barangay, NatureofService," _
& " Free, NoOfHectares, NoOfLiters, TotalAmount," _
& " AmountPaid, AmountRemaining, Remarks FROM tbltrcclient
tc inner join tbltrcservice ts on tc.ClientID = ts.ClientID " _
& " where Date LIKE '%" + DateTimePicker1.Value + "%' OR
Lastname LIKE '%" + TextBox1.Text + "%' " _
& " OR ts.Barangay LIKE '%" + ComboBox1.Text + "%' OR
NatureofService LIKE '%" + ComboBox3.Text + "%' ")
End With
DataGridView1.DataSource = myd
DataGridView1.Refresh()
DataGridView1.Columns(3).HeaderText = "Address"
DataGridView1.Columns(5).HeaderText = "Barangay"
End Sub
can you assist me on how to recode it so that i can look for a specific
record?
Cor Ligthert[MVP] - 07 Mar 2008 05:14 GMT
Enrico,
> can you assist me on how to recode it so that i can look for a specific
> record?
Sorry, no I cannot in this way, because this is completely based on your
environment. If you want to use this kind of concatinated sql string, then
simple put it in the Querry Analyzer of SQL server and simple try it.
If you want to use parameters, then start with a simple sample to try
By instance for SQL Server
dim myTable as new DataTable
dim mySqlConnection as new SqlConnection("ConnectionString")
dim SqlAdapter1 as New SqlAdapter(Select * from b where c = @b,
mySqlConnection)
SqlAdapter1.parameters.Add("@b",myval)
SqlAdapter1.Fill(myTable)
All typed here so watch typos or other failures.
Cor