Solved

fill a datagrid with a datatable

Posted on 2004-08-31
3
359 Views
Last Modified: 2010-04-23
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
0
Comment
Question by:coletteck8
3 Comments
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 125 total points
ID: 11942101
yourdatagrid.datasource = getpermitlist
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11942180
and if it is a Web application... call DataBind() method after that

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

-Baan
0
 

Author Comment

by:coletteck8
ID: 11942629
thanks so much. it worked perfectly
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question