我有麻烦试图让我的连接字符串连接到在这里我的SQL数据库文件,SQL Server数据库是我的代码SQL连接字符串
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'
错误我不断收到的是:
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)
我的SQL Server实例名称是SHAREPOINT-TEST\SHAREPOINTTESTSQ
防火墙中的端口打开:在
或者更多的细节?服务器设置为允许远程连接? –