日期:2014-05-20  浏览次数:20832 次

SQL 2008连接不上,求解
SQL Server配置管理器的SQl Server服务中除了SQL Full-text Filter Daemon Launcher(SQL)和SQl Server Agent(SQLEXPRESS),其他全部是正在运行状态,不知道是不是数据库设置不对还是source写的不对?(下面是运行的代码)

Sub Main(ByVal args() As String)

  Dim source As String = "server = local;" +
  "integrated security = SSPI;" +
  "database = MyDataBase"
  Dim selectstr As String = "SELECT [Name], [Password] FROM [UserTable]"

  Try
  Dim conn As SqlConnection = New SqlConnection(source)
  conn.Open() ''走到这里报错 

  Dim cmd As SqlCommand = New SqlCommand(selectstr, conn)
  Dim rowsReturned As Integer = cmd.ExecuteNonQuery()
  Console.WriteLine("{0} rows affect!")
  conn.Close()
  Console.WriteLine()
  Catch ex As Exception
  Console.WriteLine("12312312")
  Console.Read
  End Try

数据库名:MyDataBase
报错 内容: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)

------解决方案--------------------
大概看了一下意思,它说服务器没连上,让你检查一下是否允许远程连接
------解决方案--------------------
server = .;OK
------解决方案--------------------
探讨
SQL Server配置管理器的SQl Server服务中除了SQL Full-text Filter Daemon Launcher(SQL)和SQl Server Agent(SQLEXPRESS),其他全部是正在运行状态,不知道是不是数据库设置不对还是source写的不对?(下面是运行的代码)

Sub Main(ByVal args() As String)

Di……