black zero
Well-known member
- Joined
- Jan 15, 2009
- Messages
- 53
- Programming Experience
- Beginner
Might be a little bit hard to explain,
I have this code run on form load event:
That will load all records inside kelancaran table into a dgcrtransaksi AND column titles on cbospr. This is so far, working fine.
And there's a second code like this:
I put the second code on a textbox_change event (please see image below).
However, that code isn't working for all data types. If the column is integer, it would produce this error 'Cannot perform 'Like' operation on System.Int32 and System.String.'. But, it does work fine on VarChar type column.
FYI, here's my form screenshot:
=.= Sorry, I am stuck here... Help, please?
I have this code run on form load event:
VB.NET:
Try
Module1.OpenCon2()
da = New SqlDataAdapter("select * from kelancaran", Module1.xcon)
da.Fill(ds, "edit")
da.Dispose()
For i As Integer = 0 To ds.Tables("edit").Columns.Count - 1
cbospr.Items.Add(ds.Tables("edit").Columns(i).ToString)
Next
cbospr.SelectedIndex = 0
dv = ds.Tables("edit").DefaultView
DgCrTransaksi.DataSource = dv
Catch ex As Exception
MsgBox(ex.Message)
End Try
That will load all records inside kelancaran table into a dgcrtransaksi AND column titles on cbospr. This is so far, working fine.
And there's a second code like this:
Try
If txtFilter.Text <> "" Then
dv.RowFilter = cbospr.SelectedItem & " like '%" & txtFilter.Text & "%'"
Else
dv.RowFilter = ""
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
I put the second code on a textbox_change event (please see image below).
However, that code isn't working for all data types. If the column is integer, it would produce this error 'Cannot perform 'Like' operation on System.Int32 and System.String.'. But, it does work fine on VarChar type column.
FYI, here's my form screenshot:
=.= Sorry, I am stuck here... Help, please?