Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Taking Values from Storeprocedure into DataSet

  Asked By: Kent    Date: Jun 07    Category: Asp.net    Views: 1202
  

I know that you can use the SqlDataAdapter to FILL the dataset, from the results that you retrieve.

But using the SqlCommand that you use to specify a SP you trying to access I cant find the same method .

Can you not do this? Are there anyways around this.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Tyrone Sanchez     Answered On: Jun 07

do u mean smth like this?

in the initcomp (but this could be all done automatic if you are using VS.NET)


Private sub initializecomponent()
me.sqlConnection = new system.data.sqlclient.SqlConnection
me.sqlDataAdapter = new system.data.sqlclient.SqlDataAdapter
me.sqlCommand = new system.data.sqlclient.SqlCommand

SqlConnection.connectionString = " your connection string "

Me.SqlDataAdapter.InsertCommand = Me.SqLInsertCommand
Me.SqlDataAdapter.SelectCommand = me.SqlSelectCommand

me.SqlSelectCommand.CommandText = "[name of stored procedure]"
me.SqlSelectCommand.CommandType = System.DAta.CommandType.Storedprocedure
sqlDataAdapter.SelectCommand.Connection = SqlConnection

"Take a look after the property TableMappings.addRange

me.SqlSelectCommand.Tablemappings.addRange = "..................." => specific in your case... look after it on msdn.microsoft.com

...


end sub

=> as said, all this before could be done automaticly in Visual Studio.Net (by draging a dataadapter on the design field...)

later when u wanna use de connection...

SqlDataAdapter.Fill(myDataSet) ' dataset  has been filled automaticly ==> it take automaticly your select-command
==> when u wanna up smth => sqlDataAdapter.update(myDataSet) => automaticly takes insert, delete and update...


dataGrid.DataSource = myDataSet
dataGrid.DataMember = myDataSet
DataGrid.DataBind()



 
Answer #2    Answered By: Jonathan Brown     Answered On: Jun 07

i just see u have already solved your problem...

btw: for you dynamically controls: i've the same problem and solved it temporaly by using the visible style...
But i know this couldn't be the correct way...

 
Didn't find what you were looking for? Find more on Taking Values from Storeprocedure into DataSet Or get search suggestion and latest updates.




Tagged: