koneksinya bisa diletakkan di modul
contoh:
Public cn as new adodb.connection
Public strCnString as string
Sub Main()
strCnString = "Provider=SQLOLEDB.1;Persist Security Info=True;User
ID=sa;Initial Catalog=Milling;Data Source='NamaServer'"
cn.CursorLocation = adUseClient
cn.ConnectionString = strCnString
If cn.State <> adStateOpen Then
cn.Open
End If
End Sub
Atau bisa juga koneksinya dibuka di masing-masing form.:
Private Sub OpenConnection()
cnDailyMilling.CursorLocation = adUseClient
cnDailyMilling.ConnectionString = strCnString
If cnDailyMilling.State <> adStateOpen Then
cnDailyMilling.Open
End If
End Sub
Private Sub CloseConnection()
If cnDailyMilling.State <> adStateClosed Then
cnDailyMilling.Close
End If
Set cnDailyMilling = Nothing
End Sub
Private Sub Form_Load()
OpenConnection
End Sub
Private Sub Form_Unload()
CloseConnection
End Sub
semoga bisa membantu,
Regards,
Solikhan
On 6/12/07, Indra Satriani <[EMAIL PROTECTED]> wrote:
>
> Saya sudah buat dua form, 1 untuk set koneksi ke database sql server
> (form
> setup, sudah bisa konek dan membaca database serta tabel2nya), dan satu
> form
> lagi untuk manipulasi data di database (insert, update, delete, search
> dll).
>
> Yang ingin saya tanyakan itu gimana supaya form yang untuk manipulasi
> database itu bisa membaca koneksi dari yang sudah di tentukan di form
> setup.
> Apakah perlu dibuat satu modul khusus? Mohon penjelasannya.
>
> Program saya menggunakan reference Microsoft ActiveX Data Object 2.8Library
>
> --
> ---
> I'm sorry, I can't hear you over the sound of how awesome I am.
> http://bayuindra.web.id
> http://lea.bayuindra.web.id
> Y! : mbelienkz_01
>
> [Non-text portions of this message have been removed]
>
>
>
[Non-text portions of this message have been removed]