1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| Dim MyConnection As SqlConnection
Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
MyConnection = New SqlConnection("Server=(local); Initial Catalog='mission';" _
& " Trusted_Connection=True;")
If Not (IsPostBack) Then
Dim DS As DataSet
Dim MyCommand As SqlDataAdapter
MyCommand = New SqlDataAdapter("select distinct structure from agent", MyConnection)
DS = New DataSet()
MyCommand.Fill(DS, "structure")
MySelect.DataSource = DS.Tables("structure").DefaultView
MySelect.DataBind()
End If
End Sub
Sub GetAgent_Click(ByVal Sender As Object, ByVal E As EventArgs)
Dim SelectCmd As String = "select idagent,matricule,noms,prenoms,email,structure,qualite,objetmission,pays,ville from agent where structure = @structure"
Dim DS As DataSet
Dim MyCommand As SqlDataAdapter
MyCommand = New SqlDataAdapter(SelectCmd, MyConnection)
MyCommand.SelectCommand.Parameters.Add(New SqlParameter("@structure", SqlDbType.VarChar, 50))
MyCommand.SelectCommand.Parameters("@structure").Value = MySelect.Value
DS = New DataSet()
MyCommand.Fill(DS, "structure")
MyDataGrid.DataSource = DS.Tables("structure").DefaultView
MyDataGrid.DataBind()
End Sub
Sub MyDataGrid_Page(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)
MyDataGrid.CurrentPageIndex = e.NewPageIndex
MyDataGrid.DataBind()
End Sub |
Partager