vb - arzchinka ndp xii is 2

4
ALT + F11, gaann!!! Register/Unregister ActiveX Controls Using Regsvr32.exe If you have an ActiveX Control (OCX or DLL file) that you want to use in your program, you have to register it with windows. To register it, press on windows Start Button and choose Run... Then in the Text Box type: regsvr32 d:\YourDir\YourFile.Ocx where "d:\YourDir\YourFile.Ocx" is the full path to the ActiveX control. To unregister it, type in the text box: regsvr32 /u d:\ YourDir\YourFile.Ocx Attach Database Sql Server dengan Visual Basic 6.0 Attach database adalah kebalikan dari dettach. Jika dettach sama dengan melepaskan database, maka attach sama dengan memasang database pada sql server. di bawah ini adalah script untuk attach db: Public Sub AttachDB(ByVal sDBName As String, ByVal sFileName As String) sPass = "" sPass = "" sDBName = "XBLogistik" Dim sConn As String sConn = "Provider=SQLOLEDB.1;Password=" & sPass & ";Persist Security Info=True;User ID=" & sUser & ";Initial Catalog=" & sDBName & ";Data Source=." ExecSP2Par "sp_attach_db", "@dbname", sDBName, "@filename", sFileName, sConn

Upload: putra1429

Post on 11-Nov-2015

213 views

Category:

Documents


0 download

DESCRIPTION

s

TRANSCRIPT

ALT + F11, gaann!!! Register/Unregister ActiveX Controls Using Regsvr32.exe

If you have an ActiveX Control (OCX or DLL file) that you want to use in your program, you have to register it with windows.

To register it, press on windows Start Button and choose Run...Then in the Text Box type: regsvr32 d:\YourDir\YourFile.Ocxwhere "d:\YourDir\YourFile.Ocx" is the full path to the ActiveX control.

To unregister it, type in the text box: regsvr32 /u d:\YourDir\YourFile.Ocx

Attach Database Sql Server dengan Visual Basic 6.0

Attach database adalah kebalikan dari dettach. Jika dettach sama dengan melepaskan database, maka attach sama dengan memasang database pada sql server.

di bawah ini adalah script untuk attach db:

Public Sub AttachDB(ByVal sDBName As String, ByVal sFileName As String)

sPass = "" sPass = "" sDBName = "XBLogistik"

Dim sConn As String sConn = "Provider=SQLOLEDB.1;Password=" & sPass & ";Persist Security Info=True;User ID=" & sUser & ";Initial Catalog=" & sDBName & ";Data Source=."

ExecSP2Par "sp_attach_db", "@dbname", sDBName, "@filename", sFileName, sConn

End Sub

Dibawah ini adalah sub prosedur untuk mengeksekusi Stored Procedure yang ada di SQL Server:

Public Sub ExecSP2Par(SPName As String, sPar1Name, sPar1Value, _ sPar2Name, sPar2Value, sConn As String)

On Error GoTo localErr Dim oConn As New ADODB.Connection oConn.open sConn Dim oPar1 As New ADODB.Parameter

Dim oPar2 As New ADODB.Parameter Dim ocmd As New ADODB.Command

With ocmd .ActiveConnection = oConn .CommandType = adCmdStoredProc .CommandText = SPName Set oPar1 = .CreateParameter(sPar1Name, adVarWChar, adParamInput, 10000000, sPar1Value)

.Parameters.Append oPar1 Set oPar2 = .CreateParameter(sPar2Name, adVarWChar, adParamInput, 10000000, sPar2Value)

.Parameters.Append oPar2 .Execute

End With

oConn.Close Set oConn = Nothing

Exit Sub

localErr:MsgBox Err.Description, vbCritical Resume Next

End Sub

sp_attach_dbadalah stored prosedur bawaan sql server yang berfungsi untuk memasang database. Anda bisa mencarinya dengan Enterprise Manager di database master -> Stored Procedures

Demo Combo Box:

1. Buka project baru2. double click command button pada toolbox3. Kode di form_load adalah seperti di bawah ini:Private Sub Form_Load() Combo1.Clear Combo1.AddItem "senin" Combo1.AddItem "selasa" Combo1.AddItem "rabu" Combo1.AddItem "kamis" Combo1.AddItem "jum'at" Combo1.AddItem "sabtu" Combo1.AddItem "minggu" End Sub