Link to home
Start Free TrialLog in
Avatar of coletteck8
coletteck8

asked on

fill a datagrid with a datatable

i am fairly new to .net and need to know hot to call the function below and fill a datagrid with it. any help?
      Friend Function GetPermitList() As System.Data.DataTable
            Dim cn As SqlConnection = Me.CreateConnection()
            Dim cmd As New SqlCommand("spPermit", cn)
            Dim dt As New DataTable

            With cmd
                  .CommandType = CommandType.StoredProcedure
                  .Parameters.Add("@PermitId", SqlDbType.Int).Value = 0
                  .Parameters.Add("@Mode", SqlDbType.VarChar).Value = "SELECT"
            End With

            cn.Open()
            Dim da As New SqlDataAdapter(cmd)
            da.Fill(dt)
            cn.Close()

            Return dt
      End Function
ASKER CERTIFIED SOLUTION
Avatar of RonaldBiemans
RonaldBiemans

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DotNetLover_Baan
DotNetLover_Baan

and if it is a Web application... call DataBind() method after that

yourdatagrid.datasource = getpermitlist()
yourdatagrid.DataBind()

-Baan
Avatar of coletteck8

ASKER

thanks so much. it worked perfectly