veri tabanı bilgilerimizi saklayacağımız bir tablo yapalım
sonra bir modüle şunları yazalım
ve bu şekilde kullanabilirsiniz
sonra bir modüle şunları yazalım
Visual Basic
- Public Function verinedir() As String
-
- Dim server1 As String
- Dim datebase1 As String
- Dim user1 As String
- Dim password1 As String
- Dim komple_bag As String
-
- server1 = DLookup("[Server_IP]", "datebase", "[Server_Ip]")
- datebase1 = DLookup("[Datebase]", "datebase", "[Server_Ip]")
- user1 = DLookup("[user]", "datebase", "[Server_IP]")
- password1 = DLookup("[password]", "datebase", "[Server_Ip]")
- komple_bag = "Driver={SQL Server};Server=" & server1 & ";uid=" & user1 & ";pwd=" & password1 & ";database=" & datebase1
- verinedir = komple_bag
- VeriNe = verinedir
-
- End Function
ve bu şekilde kullanabilirsiniz
Visual Basic
- Dim cn As ADODB.Connection
- Dim rst As New ADODB.Recordset
- Dim sorgu1 As String
- Set cn = New ADODB.Connection
-
- ' @KasNo
-
-
- sorgu1 = "EXECUTE [dbo].[Kasa_Fis_Sil] " & Me.Kasa_Fis_No
-
- cn.ConnectionString = [color=#FF0000]verinedir()[/color]
- On Error Resume Next
- cn.Open
- If cn.State = adStateOpen Then
- 'MsgBox ("Baglantı Kuruldu...")
- rst.CursorLocation = adUseClient
- rst.Open sorgu1, cn, adOpenKeyset, adLockOptimistic
-
- Set Me.Recordset = rst
-
- Else
- MsgBox ("Bağlantı Kurulamıyor!!")
- End If
- rst.Close
- cn.Close
- Set rst = Nothing
- Set cn = Nothing



