Dim con As New SqlConnection Dim dbp As String Dim dbSource As String dbp = "Data Source=.\SQLEXPRESS" dbSource = "Data Source=C:\Users\Administrator\Documents\mydata.mdf" con.ConnectionString = dbp & dbSource con.Open() MsgBox("DataBase is Now Open") con.Close() MsgBox("Database is Now Closed")
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 25 - Connection string is not valid)
Server=.\SQLExpress;AttachDbFilename=FilePathHere;Database=DatabaseNameHere; Trusted_Connection=Yes;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)