Imports System.Data
Imports System.Data.SqlClient
Partial Class Uploads_Uploadpic
Inherits System.Web.UI.Page
Dim objConn As SqlConnection
Dim objCmd As SqlCommand
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
BindData()
End Sub
Protected Sub BindData()
Dim dtAdapter As New SqlDataAdapter
Dim ds As DataSet
Dim strSQL As String
Dim strConnString As String
strConnString = "Server=localhost;uid=sa;password=xxxx;database=xxxx;Max Pool Size=400;Connect Timeout=600;"
objConn = New SqlConnection(strConnString)
objConn.Open()
strSQL = "SELECT * FROM Login"
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds)
'Dim dtReader As SqlDataReader
'objCmd = New SqlCommand(strSQL, objConn)
'dtReader = objCmd.ExecuteReader()
GridView1.DataSource = ds
GridView1.DataBind()
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
End Sub
Sub Page_UnLoad()
objConn.Close()
objConn = Nothing
End Sub
Sub ShowPageCommand(ByVal s As Object, ByVal e As GridViewPageEventArgs)
GridView1.PageIndex = e.NewPageIndex
BindData()
End Sub
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim Count_id As String
Dim lblID As Label = CType(e.Row.FindControl("lblID"), Label)
If Not IsNothing(lblID) Then
Count_id = e.Row.DataItem("Login_ID")
lblID.Text = Count_id
lblID.Visible = False
End If
Dim hylName As HyperLink = CType(e.Row.FindControl("hylName"), HyperLink)
If Not IsNothing(hylName) Then
hylName.Text = e.Row.DataItem("Staff_Name")
hylName.NavigateUrl = "Admin_Data.aspx?idlogin=" & Count_id
End If
Dim lblPicture As Label = CType(e.Row.FindControl("lblPicture"), Label)
If Not IsNothing(lblPicture) Then
lblPicture.Text = IIf(IsDBNull(e.Row.DataItem("Picture")), String.Empty, e.Row.DataItem("Picture"))
End If
End Sub
End Class
Dim dtAdapter As New SqlDataAdapter
Dim ds As DataSet
Dim strSQL As String
Dim strConnString As String
strConnString = "Server=localhost;uid=sa;password=xxxx;database=xxxx;Max Pool Size=400;Connect Timeout=600;"
objConn = New SqlConnection(strConnString)
objConn.Open()
strSQL = "SELECT * FROM Login"
objCmd = New SqlCommand
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds)