从VB导出SQL到表的数据访问

时间:2013-05-31 06:27:22

标签: sql vb.net excel export

根据以下代码,显示的错误为Type 'DataAccess' is not defined。我应该导入什么以删除此错误?

Protected Sub ExportPOS(ByVal sender As Object, ByVal e As DirectEventArgs)
              Handles ExportButton.Click

    Try
    Make Connection

    Dim cnn As DataAccess = New DataAccess(Libatelconnectionstring)
        ........

1 个答案:

答案 0 :(得分:0)

尝试此例程(来自MSDN)..

Public Sub ConnectToAccess()
    Dim conn As New System.Data.OleDb.OleDbConnection()
    ' TODO: Modify the connection string and include any
    ' additional required properties for your database.
    conn.ConnectionString = & _
    "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & _
    "C:\Documents and Settings\username\My Documents\dbFile.mdb"
    Try
       conn.Open()
       ' Insert code to process data.
    Catch ex As Exception
       MessageBox.Show("Failed to connect to data source")
    Finally
       conn.Close()
    End Try
End Sub