Solved

fill a datagrid with a datatable

Posted on 2004-08-31
3
356 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
Comment Utility
yourdatagrid.datasource = getpermitlist
0
 
LVL 18

Expert Comment

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

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

-Baan
0
 

Author Comment

by:coletteck8
Comment Utility
thanks so much. it worked perfectly
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now