紧急求救,vb.net连不到sql server2000数据库??
Imports System.DataImports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
'数据库连接对象
Dim objConnection As SqlConnection = New SqlConnection("server=(local);database=
(pubs);user id=sa;password=")
'数据适配器
Dim objDataAdapter As SqlDataAdapter = New SqlDataAdapter()
'DataSet
Dim objDataSet As DataSet = New DataSet()
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
'设置查询命令属性
objDataAdapter.SelectCommand = New SqlCommand
objDataAdapter.SelectCommand.Connection = objConnection
objDataAdapter. = "select au_lname,au_fname,title,price
from authors join titleauthor on authors.au_id=titleauthor.au_id join titles on
titleauthor.title_id=titles.title_id order by au_lname,au_fname"
objDataAdapter. = CommandType.Text
'打开数据库连接
objConnection.Open()
'填充DataSet对象
objDataAdapter.Fill(objDataSet, "authors")
'关闭数据库连接
objConnection.Close()
'给DataGrid绑定数据
grdAuthorTitles.DataSource = objDataSet
grdAuthorTitles.DataMember = "authors"
'清除
objDataAdapter = Nothing
objConnection = Nothing
End Sub
End Class
上面是代码,连接的时候,在objConnection.Open()在这句话上出现了异常,提示:无法打开登录 '(pubs)' 中请求的数据库。登录失败。 用户 'sa' 登录失败。
在sql 2000上,用户名sa,密码为空,就可以登陆,1433端口也开着
请高手帮忙看看是怎么回事???