Private Sub Text1_KeyPress(keyascii As Integer)
on error goto errHandle
If keyascii = 13 Then
Set DataGrid1.DataSource = nothing
set con = nothing
Set con = New Connection
With con
.Provider = "SQLOLEDB"
.ConnectionString = "User ID=sa;Password=sql;Persist
Security Info=True;Initial Catalog=table;Data Source=SQL"
.Open
End With
set com=nothing
Set com = New Command
With com
.ActiveConnection = con
.CommandText = "select A from table01"
.CommandType = adcmdtext
.Execute
End With
set rst=nothing
Set rst = New Recordset
rst.CursorLocation = adUseClient
rst.LockType = adLockOptimistic
rst.CursorType = adOpenStatis
set rst.source = com
rst.open
Set DataGrid1.DataSource = rst
Datagrid1.refresh
endif
exit sub
errHandle:
msgbox err.description
end sub
aksan kurdin
ps. sebaiknya connection dan command di inisial di event load dari form.
Pada tanggal 9/7/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> menulis:
> Dear pakar VB
>
>
> Saya ada 2 pertanyaan :
>
> 1. Dimana letak kesalahan prosedure key press ini ya ...saya ingin setelah
> ditekan enter pada textbox1 muncul datagrid yg isinya hanya field A pada
> tabel01
> 2. Pada datagrid yg muncul ini jika field A ada 2 atau lebih yg muncul
> hanya satu saja. ( sehingga di table02 field A unik )
>
> mohon perbaikannya ...
>
> Tabel01
>
> A B C
>
> 01 Saya ayam
> 02 Aku bubur
> 01 ane kisi
> 03 ty a
> 04 er b
> 03 ert b
>
> Tabel02
>
> A D E
>
> 01 - -
> 02 - -
> 03 - -
> 04 - -
>
>
> Private Sub Text1_KeyPress(keyascii As Integer)
> Set con = New Connection
> Set rst = New Recordset
> Set rst1 = New Recordset
> Set com = New Command
>
> rst.CursorLocation = adUseServer
> rst.LockType = adLockOptimistic
> rst.CursorType = adOpenDynamic
>
> rst1.CursorLocation = adUseServer
> rst1.LockType = adLockOptimistic
> rst1.CursorType = adOpenDynamic
>
>
> With con
> .Provider = "SQLOLEDB"
> .ConnectionString = "User ID=sa;Password=sql;Persist Security
> Info=True;Initial Catalog=table;Data Source=SQL"
> .Open
> End With
>
> With com
> .ActiveConnection = con
> .CommandText = "select A from table01"
> .Execute
> End With
>
> rst1.Open "select A from tabel01", con
>
> If keyascii = 13 Then
> DataGrid1.Visible = True
> Set DataGrid1.DataSource = rst1 '===> the rowset is not bookmarkable
>
>
> endif
> end sub
>
>
>
> salam
>
> haris
>
> [Non-text portions of this message have been removed]
>
>
>
>
> Untuk berhenti berlangganan kirim email kosong ke : [EMAIL PROTECTED]
>
> Ikuti juga forum diskusi VB.net dengan
> mengirim email kosong ke [EMAIL PROTECTED]
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/zCsqlB/TM
--------------------------------------------------------------------~->
Untuk berhenti berlangganan kirim email kosong ke : [EMAIL PROTECTED]
Ikuti juga forum diskusi VB.net dengan
mengirim email kosong ke [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/indoprog-vb/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/