Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


VB.Net and stored Procedures

Posted on 2004-10-24
Medium Priority
Last Modified: 2010-04-23
I have some code which calls a stored procedure

Dim cn As New SqlConnection("Data Source=localhost; Initial Catalog=lergdb; User ID=sa; Password=")

Dim Sql As String
Sql = "sp_getNpaInfo"

Dim cmd As New SqlCommand(Sql, cn)
cmd.CommandType = CommandType.StoredProcedure

cmd.Parameters.Add("@npa", 949)
cmd.Parameters.Add("@nxx", 489)

Dim dr As SqlDataReader = cmd.ExecuteReader()

i would to like to be able to do the folowing...

a) bind the resault to a controle like a grid or so...
b) read dat data into a table of a dataset
c) able to tell how many rows are in the resault..

Question by:AlexPonnath
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
  • 2
LVL 34

Expert Comment

ID: 12396583
1 and 2

This is for oleDb, just modify to suit slq

dim adpt as new oledbAddapter
dim ds as new dataset
adpt.SelectCommand = cmd
ds = New DataSet
adpt.Fill(ds, "myTable")
me.myDatagrid.datasource = ds.tables("myTable")
'dont forget to close and dispose you objects




numCols = ds.tables("myTable").columns.count

Dont have VS .Net on me, so please mind the air code (all done off the top of my head)

LVL 15

Accepted Solution

Timbo87 earned 2000 total points
ID: 12397121
1 and 2:

Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "TableName")
dataGrid1.DataSource = ds.Tables("TableName").DefaultView

LVL 34

Expert Comment

ID: 12397129
>> numCols = ds.tables("myTable").columns.count

Damn i'm an idiot

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

618 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