Solved

fill a datagrid with a datatable

Posted on 2004-08-31
3
361 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

742 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