Private connectionstring As String = "provider=sqloledb.1; data source=localhost; initial catalog=pubs; integrated security=sspi "
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
If Me.IsPostBack = False Then
createlist()
End If
End Sub
Private Sub createlist()
Dim selectsql As String
selectsql = "select au_lname,au_fname,au_id from authors "
Dim con As New OleDbConnection(connectionstring)
Dim cmd As New OleDbCommand(selectsql, con)
Dim adapter As New OleDbDataAdapter(cmd)
Dim dspubs As New DataSet
Try
con.Open()
adapter.Fill(dspubs, "authors ") '这里错了!!!!!!
cmd.CommandText = "select au_id,title_id from titleauthor "
adapter.Fill(dspubs, "titleauthor ") '还有这里!!!!!!
cmd.CommandText = "select title_id,title from titles "
adapter.Fill(dspubs, "titles ") '问题都一样!!!!!!
Catch err As Exception
lbllist.text = "error reading list of names. "
lbllist.text &= err.Message
Finally
If (Not con Is Nothing) Then
con.Close()
End If
End Try