Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid Control not show data

Status
Not open for further replies.

joseprez

Vendor
Sep 7, 2002
19
0
0
PA
The follow code works, when I search a complete names like "MARK", but when I search names that begin with letter "M" (for example), DataGrid Control is in blank

this is the code:

Dim con As ADODB.Connection
Set con = New ADODB.Connection
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

With con
.ConnectionString = "Data Source=" & App.Path & "\sales.mdb"
.Provider = "Microsoft.Jet.OLEDB.4.0;"
.Open
End With

<< here is the problem >>
sql = &quot;SELECT * FROM employee WHERE Name like 'J*'&quot;
<< when I write, ... Name like 'JOHNSON'&quot; ... work >>
<< but, when I write, ... Name like 'J*'&quot; ... not work >>

With rs
.ActiveConnection = con
.Source = sql
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.Open
End With

Set DataGrid1.DataSource = rs

How solve this?
 
Try this

>>
sql = &quot;SELECT * FROM employee WHERE Name like 'J%'&quot;

Use '%' instead of '*' as a wild character in your SQL
Query.

Hope it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top