1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Public Sub configconnectionstring()
Dim key As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("Software\Médiathèque", True)
If key Is Nothing Then
Dim ar As DataTable
ar = Sql.SqlDataSourceEnumerator.Instance.GetDataSources
Dim computername As String = My.Computer.Name
Dim datasource As String = ""
For Each row As DataRow In ar.Rows
If row.Item(0).ToString = computername Then
If row.Item(1).ToString <> "" Then
datasource = computername + "\" + row.Item(1).ToString
Else
datasource = computername
End If
Exit For
End If
Next
Dim rc As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("Software", True).CreateSubKey("Médiathèque")
rc.SetValue("Connectionstring", "Data Source=" & datasource & ";AttachDbFilename=|DataDirectory|\Médiathèque.mdf;Initial Catalog=;Integrated Security=True;User Instance=True")
ar.Dispose()
End If
End Sub |
Partager