DataSource Controls :: Populating Data From A Stored Procedure / How To Manage
Apr 11, 2010
I'm looking for a steer on how to go about running stored procs efficiently.
I have a current requirement to populate a control, so I have all the specific data i.e the parameter value I need to pass and the control I want to populate, plus generic data such as SqlConnection etc.
I'd like to be able to call, say, "MyStoredProc". MyStoredProc would contain all the necessary information to run the proc, but then pass onto a method, say, GetSpData, which contained all the generic stuff about running stored procs.
Then when setting up MyStoredProc2 I could do without repeating a lot of the original function
Im I barking up the wrong tree or is there an efficient way of managing this kind of situation.
I need to populate a text box from a stored porcedure call that does not have any parameters. I've made the database connection and am executing the stored procedure, but I cannot figure out how to set a text box value to the return value of the stored procedure. BTW, the stored procedure only returns one value.
I have a form that has a textbox, a button and a datagridview. The textbox is a parameter of @subschedule. I'm needing to pass the value of the text box to my sql stored procedure and then fill my datagridview with the results of that query.
Initially, I have tried to use stored procedure. But I changed my mind and preferred to call sql query in codebase with command text. However, it stills tries to find initially-called stored procedure (which is neither called or exists).I think that it is related caching. But I tried it with different browsers it did not work.What might be the reason?
I have a DAL for accessing data from sql server in my asp.net 3.5 application.
[code]....
Here I am passing parameter and connection string. I want to create a common method which i can use for anywhere. I don't want to specify parameter datatype. sometime i have 3 or 4 parameter.
The database I am using has a schema called EQB and as such, my stored procedures are named as EQB.usp_SelectFunds, EQB.usp_SelectAccount, etc.
On the select tab of the Configure Data Source screen, I choose to use a stored procedure. The dropdown shows my stored procedures, however, the schema name does not show up in front of the stored procedures in the drop down. I see only usp_SelectFunds, usp_SelectAccount, etc.
I select one of the stored procedures and when I click TEST, I get the message that the stored procedure is not found. If I instead choose to use a SQL statement instead on the configuration screen and enter EXEC EQB.usp_SelectFunds and click TEST, it works fine.
Why are my stored procedures not showing up correctly in the stored procedure drop down and how can I fix this?
I am bulding a dvd catalog and have a table called DVD which holds all my details about each dvd except Genre, Director and Actor as I want more than 1 Genre, Director, Actor per DVD so put these in seperate tables to avoid repeating the data and used a joining tabe to join the tables so the tables I have are
DVD, Genre, Director, Actor, DVDGenre, DVDDirector and DVDActor
I have now written a stored procedure to pull the info about 1 DVD out of all the tables to display on the webpage I have now got the info I want out of the tables but as the data is now in 1 table I have repeating data is there a way to stop the data repeating the stored procedure i have written is
i have a grid bound to sqldatasource control which gets its data from stored procedure. in page load event i code a dropdownlist where i take the selectedvalue parameter for the parameter query. only when a second dependant dropdownlist is selected (coded in dropdownlist1 selected event)is data returned ?
I'm using below stored procedure to reterive data and i'm displaying it in datalist... Now i want to reterive data from two tables by using this stored procedure...collegedetails is my table name... I want data from coursedetails also.
CREATE PROCEDURE [dbo].[SearchInstitute] @startRowIndex int, @Category varchar(500), @inst_name varchar(500), @course_name varchar(500), @city varchar(500), @pageSize int, @totalCount int output AS BEGIN SET NOCOUNT ON; SET @totalCount = 0 SET @startRowIndex = @startRowIndex + 1 BEGIN SELECT * FROM ( SELECT distinct *, ROW_NUMBER() OVER (ORDER BY ArticleList.clgid DESC) as RowNum FROM ( Select distinct collegedetails.* FROM collegedetails WHERE category like '%' +@Category+ '%' OR inst_name like '%' +@inst_name+ '%' Or city like '%' +@city+ '%' ) as ArticleList ) as ArticleList1 WHERE RowNum BETWEEN @startRowIndex AND (@startRowIndex + @pageSize) - 1 ORDER BY clgId DESC SELECT distinct @totalCount = Count(clgId) FROM collegedetails WHERE category like '%' +@Category+ '%' OR inst_name like '%' +@inst_name+ '%' Or city like '%' +@city+ '%' END END
More specifically, i'm trying to create a stored procedure that displays data from a table if the date column in the table matches a specific day of the week. (IE. Monday, Tuesday, ect...)
I am building a WCF Web Service that has a Business Logic layer (that implements all validation logic and other business rules) and a Data Access Layer that makes calls to Stored Procedures in my database.
I would like to be able to validate the length of data passed against that of the length of the parameters in the Stored Procedures without having to explicitly define the parameter lengths in my WCF Web Service.
Eg:
Person Object Person.Name = "John Dhoe" Person.Age = 37 SQL Stored Procedure SavePerson FullName Varchar(15) Age Int
In my BLL or DAL, I would like to be able to do something like :
I am trying to write a function that can be called to run a stored procedure. I pass the stored procedure name, followed by as many parameters as I need to run the procedure. I am able to do this by using the params keyword, so my function looks something like this;
[Code]....
How can I determine what the data type of the parameter is? Maybe I need to alter the string[] part, above?
i have a stored procedure with this values and i need just to make a button that will send something to "Equip" column,how to do it? write the values on my webpage and make a button to exec the procedu
I created a database on SQL Server 2005 developer edition with MS SQL Server Mangement Studio Express. Now I created code that accessess a stored procedure named 'pS_TableData'. However I have one problem the code raises an exception "Could not find stored procedure 'pS_TableData 'Letters''."the code looks like this:
[Code]....
Note I am using (for now) the same connection that I used to create my database so in essence my web site is the administrator. I tried a simple SELECT from a table with the same connection and it raised no exceptions!When I run EXECUTE ps_TableData 'Letters' in SSMS it has no . I also tried EXECUTE ps_TableData 'Letters' as the command paramated for SqlCommand but it had the same effect
I call this stored procedure with a dataset. It always returns a 0 but should return a 1 or 2. Does anybody know why it isn't returning a 1 or 2.
ALTER PROCEDURE dbo.sp_InsertLinkVote @LinkId int, @LinkVoter nvarchar(50), @LinkVotesDateTime datetime, @LinkVotesGoodBad bit AS /* SET NOCOUNT ON */
If EXISTS (SELECT * FROM LinkVotes WHERE LinkId=@LinkId and LinkVoter = @LinkVoter )RETURN 1 ELSE INSERT INTO dbo.LinkVotes (LinkId,LinkVoter,LinkVotesDateTime,LinkVotesGoodBad)VALUES (@LinkId,@LinkVoter,@LinkVotesDateTime,@LinkVotesGoodBad)RETURN 2
Here is were a call it in my code behind. Dim VoteCheck As Integer Dim InsertVote As New DataSetStoredProceduresTableAdapters.QueriesTableAdapter VoteCheck = InsertVote.sp_InsertLinkVote(LinkId, User.Identity.Name, DateAndTime. Now, True) '0 is a good vote. If VoteCheck = 0 Then
It seems to insert and not insert correctly, I just cannot get it to return the correct value.
I am developing a page in ASP.Net where I have the user enter a letter into a textbox. They then click a submit button and I all of the userids that start with that letter are to be displayed. So I need the SP to go through the database and match first letters with what was entered. Here is what I have as my code for the SP:
CREATE PROCEDURE dbo.exp2 @testchar Char(1) declare @flag as char(2) set @flag = @testchar + '%' select userid from ex_database where userid like @flag
So I'm working with SQL Server 2005 and I'm having trouble saving a stored procedure. (I've only used an Apache server before, and for nothing as complex as the project I'm working on)
Nonetheless, the problem is that I don't know where to actually save the stored procedure I create. In my Object Explorer, I go to the database I want to create it in, expand Programmability, right click on Stored Procedures and choose to create a new one. That's all nice, but when I'm ready to save and test it from my webpage, it asks where to save it. This is probably dumb of me, but I don't know where to. I try to save it on the desktop and click/drag to the Stored Procedures folder in my database, but all that does is open it, not actually store it in the database. Maybe I'm getting the point of stored procedures wrong? Let me know what I should do to save it in the right place so I can access it.