当前位置: 编程技术>.net/c#/asp.net
使用SqlConnection将数据绑定到DataGrid中(VB.NET)
来源: 互联网 发布时间:2014-08-30
本文导语: 使用SqlConnection方式将数据绑定到DataGrid中,代码如下: 代码示例: Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs) Dim DBConn as SQLConnection Dim DBCommand As SQLDataAdapter Dim DSPageData as New DataSet ' DBConn = New...
使用SqlConnection方式将数据绑定到DataGrid中,代码如下:
代码示例:
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
Dim DBConn as SQLConnection
Dim DBCommand As SQLDataAdapter
Dim DSPageData as New DataSet
' DBConn = New SQLConnection("server=localhost;" _
' & "Initial Catalog=TT;" _
' & "User Id=sa;" _
' & "Password=yourpassword;")
DBConn = New SQLConnection("Data Source=whsql-v08.prod.mesa1.secureserver.net;Initial Catalog=DB_49907;User ID=java2suser;Password='password';")
DBCommand = New SQLDataAdapter _
("Select LastName as [Last Name], " _
& "FirstName as [First Name], " _
& "Salary as [Current Salary] " _
& "from Employee", DBConn)
DBCommand.Fill(DSPageData, _
"EmployeesAll")
dgEmps.DataSource = _
DSPageData.Tables("EmployeesAll").DefaultView
dgEmps.DataBind()
End Sub
使用SqlConnection方式将数据绑定到DataGrid中-www.