==========================
- cara koneksi database yg sdh dipelajari di Prog
2 = MS Access, MS SQL Server (local)
- di prog 3 ini
- MS SQL Server 2008 --> client/server
- nama server
- IP
- Nama SERVER database SQL Server
- Start -> All Program -> Microsoft SQL Server
2008 -> SQL Server Management Studio
- start/stop = Start -> Control Panel ->
Administrative Tools -> Service
- SETTING usernama - password ( SQL Authentication
)
caranya :
- koneksi dgn windows authentication
- sorot nama server -> klik kanan ,
properties -> sorot security : ubah
pilih sql server dan login only ..
- restart database
- sorot security -> klik kanan , new login
buatlah username dan password ,
(sekaligus punya database apa/ master)
- diskonek sql server
- konek lagi dgn sql server authentication
dan username/passsword.
- merubah koding
http://mugi.or.id/blogs/ekosaint93/archive/2013/10
/12/cara-mengkoneksikan-vb-net-ke-sql-server-
2008.aspx
MODUL KONEKSI
Imports System.Data.SqlClient
Module modulkoneki
Public conn As SqlConnection
Public cmd As SqlCommand
Public ds As DataSet
Public adapter As SqlDataAdapter
Public rd As SqlDataReader
Public lokasidb As String
Public Sub ambilkoneksi()
lokasidb = "Data Source=.;Initial
Catalog=Pembelian;Persist Security Info=True;User
ID=beli; password=beli"
conn = New SqlConnection(lokasidb)
Try
If conn.State = ConnectionState.Closed
Then
conn.Open()
MsgBox("Koneksi ke database
berhasil", MsgBoxStyle.Information, "Informasi")
End If
Catch ex As Exception
MsgBox(Err.Description,
MsgBoxStyle.Critical, "Error")
End Try
End Sub
End Module
Form1
-----
Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Call ambilkoneksi()
End Sub
End Class
Tidak ada komentar:
Posting Komentar