Basically any commands for manipulating databases perform well, add or update definitely needs an operation connection, and therefore do not need to create a script that repeatedly the connection needs to be made in connection script in the module file. And if necessary just call use the command "Call <procedurename>"
Step 1
Open a new project, select the Enterprise.
Click the Project menu, click Add Module, click OK
Enter the following code in the module, then Save, ..
---
Option Explicit
Public conn As ADODB.Connection
Public recset As ADODB.Recordset
Public Sub opendb()
Set oConn = New ADODB.Connection
Set recset = New ADODB.Recordset
oConn.CursorLocation = adUseClient
oConn.Open "Provider=SQLOLEDB.1;Password=b217an;User ID=sa;Initial Catalog=Xserver;Data Source=local"
End Sub
---
Step 2
They will just call the procedure in the form with the Call command, if the sample is placed at the time the form was called / load:
Private Sub Form1_Load()
Call opendb
Set recset = New ADODB.recordset
recset.Open ("select * from data_pegawai"), oConn
DataGrid1.Data Source = recset
'----in order to save memory resources and then close again
recset.Close
Set recset = Nothing
oConn.Close
End Sub
Friday, September 20, 2013
Making a connection to SQL Server 2000-2008 VB6
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment