?
Solved

dataset connection help

Posted on 2008-10-28
3
Medium Priority
?
227 Views
Last Modified: 2012-05-05
how do i do so my connection becomes connected to my stored procedure and also dont want db connection to show on page.  example below and code to be tweaked is at the end of page

_________this is the idea______________________________________________

   Dim strConn2 As String = ConfigurationManager.ConnectionStrings("test").ConnectionString
        Dim conn2 As New SqlConnection(strConn2)
 
        conn2.Open()
     
        Dim cmd2 As New Data.SqlClient.SqlCommand("wmItemOptionproductsSp", conn2)
        cmd2.CommandType = CommandType.StoredProcedure

        cmd2.Parameters.AddWithValue("@item", Request.QueryString("option"))

_________________________________________________________________________

______________________this is the dataset that needs to be tweaked ___________

    Dim ad As New SqlDataAdapter("SELECT CategoryName,Description FROM Categories", myConnection)
        Dim ds As New DataSet()
        ad.Fill(ds, "Categories")
0
Comment
Question by:gianitoo
[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
  • 2
3 Comments
 
LVL 16

Expert Comment

by:ororiole
ID: 22827066
I dont understand what it is you are trying to do. Do you want to use the stored procedure to fill the dataset INSTEAD of the current sql command? Or are you trying to add another table to the dataset, where the new table is the result of the stored proc call?
0
 
LVL 1

Author Comment

by:gianitoo
ID: 22830185
trying to connect through stored procedure instead of writing the query on page.  i wrote the example of a connection that i have on top as reference of what i am trying to achieve.  
0
 
LVL 16

Accepted Solution

by:
ororiole earned 2000 total points
ID: 22834165
Ok, you dont need to open the connection cause dataAdapter does that for you. But it shouldnt hurt. So you have 90% of it. All you have to do is change this one line :
Dim ad As New SqlDataAdapter("SELECT CategoryName,Description FROM Categories", myConnection)

to the one shown below.

  Dim strConn2 As String = ConfigurationManager.ConnectionStrings("test").ConnectionString
        Dim conn2 As New SqlConnection(strConn2)    
        Dim cmd2 As New Data.SqlClient.SqlCommand("wmItemOptionproductsSp", conn2)
        cmd2.CommandType = CommandType.StoredProcedure
 
        cmd2.Parameters.AddWithValue("@item", Request.QueryString("option"))
 
   Dim ad As New SqlDataAdapter(cmd2)
        Dim ds As New DataSet()
        ad.Fill(ds, "TableName")

Open in new window

0

Featured Post

Independent Software Vendors: 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 article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
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…
Suggested Courses

752 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