Solved

fill a datagrid with a datatable

Posted on 2004-08-31
3
360 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

740 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