vb.net 提取SQL2000中的数据,怎么提取的数据显示不出?
’运行给出的提示是:用户"(null)"登录失败。原因:未与信任SQL Server连接相关联。怎么解决?Imports System.Data.SqlClient
Public Class Form1
Dim constr As String = "server=20091026-1144;database=公司"
Dim con As New SqlClient.SqlConnection(constr)
Dim com As New SqlClient.SqlCommand("select distinct 部门名称 from 部门表", con)
Dim ada As New SqlClient.SqlDataAdapter("select * from 职员表", con)
Dim com1 As New SqlClient.SqlCommand("select distinct 学历 from 职员表", con)
Dim reader As SqlClient.SqlDataAdapter
Dim ds As New DataSet
Dim row As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim reader As SqlClient.SqlDataReader
If con.State = ConnectionState.Closed Then
con.Open()
End If
reader = com.ExecuteReader
While reader.Read
Me.ComboBox1.Items.Add(reader(0))
End While
con.Close()
If con.State = ConnectionState.Closed Then
con.Open()
End If
reader = com1.ExecuteReader
While reader.Read
Me.ComboBox2.Items.Add(reader(0))
End While
con.Close()
If con.State = ConnectionState.Closed Then
con.Open()
End If
ds.Clear()
ada.Fill(ds, " 职员表")
Me.DataGrid1.DataSource = ds.Tables("职员表")
End Sub
End Class
--------------------编程问答-------------------- 连接字符不对,接分,答案上个帖回过了
补充:.NET技术 , VB.NET