I am having trouble trying to get my connection string to connect to my SQL Database file here is my code
Dim myConn As SqlConnection
Dim cmd As SqlCommand
Dim sqlstring as string
'Difines what database i would like to use '
myConn = New SqlConnection("Data Source=SHAREPOINT-TEST;AttachDbFilename=\\sharepoint-test\SPD\MSSQL\Data\ProblemsAndActions.mdf")
'Opens the connection to the database'
myConn.Open()
'inserts into database what table and what information relevant to what variable line in table Master'
sqlstring = "INSERT INTO Master (Id, Raised_By, Customer, Complainant_Details, Product_Code_Affected, Description_Of_Product, Qty_Affected, Batch_Affected, End_Customer, Order_Number, Consignment_Number, Details_Of_Complaint, Severity_Rating) VALUES ('" + L1 + "','" + L2 + "','" + L3 + "','" + L4 + "','" + L5 + "','" + L6 + "','" + L7 + "','" + L8 + "','" + L9 + "','" + L10 + "','" + L11 + "','" + L12 + "','" + L13 + "')"
cmd = New SqlCommand(sqlstring, myConn) 'comands to insert the above line ^'
cmd.ExecuteNonQuery() 'execute the command'
myConn.Close() 'closes connection to database'
Error I keep getting is:
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
My SQL Server instance Name is SHAREPOINT-TEST\SHAREPOINTTESTSQ