[asp.net]使用sqldataAdapter下sql讀取資料到datatable(SqlConnection)

  • 4648
  • 0
  • 2012-06-01

摘要:[asp.net]使用sqldataadapter下sql讀取資料到datatable


Dim strSQL As String = " select * from Employees where EmployeeID='" & empid & "'"
        Dim cn As SqlConnection
        Dim da As SqlDataAdapter
        Dim dt As DataTable = New DataTable
        Try
            cn = New SqlConnection(strCn)
            da = New SqlDataAdapter(strSQL, cn)
            da.Fill(dt)
            Dim temp As String
            temp = ""
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

簡單吧!