SqlDataSource Returns RowCount
Apr 22, 2006
Hello Dears;
I added an SqlDataSource to count rows number and display it in the footer of GridView. but idon't know how to refer to that ogject to display the rowcounts. I tried to declare it with Dim but didn't worked out.
Any Idea , pleas?
Thanks alot
View 4 Replies
ADVERTISEMENT
Mar 8, 2007
HiI'm using a simple SqlDataSource to connect to a stored proc to delete a number of rows from different tables.In my SQL im using: DECLARE @table1Count int
DELETE FROM Table1 WHERE id = @new_id
SET @table1Count=@@rowcount
SELECT @table1Count I'm then using an input box and linking it to the delete control parameter. Then on a button click event i'm running SqlDataSource1.Delete() which all works fine. But how do i get the @table1Count back into my aspx page? Thanks
View 3 Replies
View Related
Mar 21, 2007
I have a Gridview bound to a SQLDataSource that uses a Stored Procedure expecting 1 or 2 parameters. The parameters are bound to textbox controls. The SP looks up a person by name, the textboxes are Last Name, First Name. It will handle last name only (ie. pass @ln ='Jones' and @fn=null and you get all the people with last name=Jones. I tested the SP in Management Studio and it works as expected. When I enter a last name in the Last Name textbox and no First Name I get no results. If I enter a Last Name AND First Name I get results. I don't understand.
Here's the HTML View of the page. The only code is to bind the Gridview when the Search button is pressed.
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TextBox1" runat="server" TabIndex=1></asp:TextBox> <asp:TextBox ID="TextBox2" runat="server" TabIndex=2></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Search" TabIndex=3 /> <hr /> </div> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" DataSourceID="SqlDataSource1" DataKeyNames="EmpID" CellPadding="4" EnableSortingAndPagingCallbacks="True" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False"> <Columns> <asp:BoundField DataField="EmpID" HeaderText="Emp ID" ReadOnly="True" SortExpression="EmpID" /> <asp:BoundField DataField="FullName" HeaderText="Full Name" SortExpression="FullName" /> <asp:BoundField DataField="Nickname" HeaderText="Nickname" ReadOnly="True" SortExpression="Nickname" /> <asp:BoundField DataField="BGS2" HeaderText="BGS2" SortExpression="BGS2" /> <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" /> <asp:BoundField DataField="email" HeaderText="Email" SortExpression="email" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:EmpbaseConnectionString %>" SelectCommand="GetByName" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="TextBox2" Name="fn" PropertyName="Text" Type="String" ConvertEmptyStringToNull=true/> <asp:ControlParameter ControlID="TextBox1" Name="ln" PropertyName="Text" Type="String" ConvertEmptyStringToNull=true/> </SelectParameters> </asp:SqlDataSource> </form> </body></html>
View 7 Replies
View Related
Aug 3, 2007
I have a query that I created in SqlServer and then merely copied the code to a sqldatasource. They are both connected to the same db, however the sqldatasource query only returns 6 records and when run in SqlServer, it returns 52 rows which is the correct number.
Any ideas on what might be causing this? There are no filters on the sqldatasource. It only has that one query. Do they differ in the way they execute sql code?
Thanks for any help!
View 1 Replies
View Related
Jul 7, 2006
I have a vb.net application that executes a simple flat file to sql table dtsx package. I want to capture the rowcount to display back to the user to verify the number of rows that were inserted or updated to the table. I have a Row Count component placed between the flat file source(without errors) and the destination component. I have assigned a variable named RecordCount to the Row Count component. So far so good I hope : )
Now, I also use a variable to "feed" the package the flat file source. This works fine, but I cannot figure out how to retrieve the row count information and how to assign that to the variable RecordCount.
Also, if anyone has any insight on the way to work with the OnProgress method in SSIS I would appreciate that as well. In SQL 2000 using DTS I create a "PackageEventsSink" that I had found online, and it worked great for monitoring the progress of the DTS. Can't seem to figure out how to get it to work in SSIS.
Thanx,
Mike
View 11 Replies
View Related
Jul 25, 2007
In sql I perform the following
SELECT * FROM
xlsdci x LEFT OUTER JOIN fffenics f ON f.[derived deal code] = x.[manual dcd id]
which gives me a row count of 2709 rows
In SSIS I have a merge join component (left outer)
left input = xlsdci with a sort order of 1 ASC on [manual dcd id] (OLE DB source component)
right input = fffenics with a sort order of 1 ASC on [derived deal code] (OLE DB source component)
which when run in the IDE gives me a rowcount of only 2594 rows
Why is this so?
Also if I change the join to INNER in the merge join, the number of rows drops dramatically to only 802.
Fair enough, I hear you cry, maybe there are IDs in the 'xlsdci' table that are not in the 'fffenics' table. Ok. But the following SQL reveals that there are only 14 rows(IDs) in 'xlsdci' that are not in 'fffenics'
SELECT * FROM xlsdci
WHERE [manual dcd id] NOT IN (SELECT [derived deal code] FROM dbo.fffenics)
What is going on here?
View 5 Replies
View Related
Jul 23, 2005
Grrr!I'm trying to run a script:print 'Declaring cursor'declare cInv cursor forward_only static forselectdistinctinv.company,inv.contact,inv.address1,inv.city,inv.state,inv.postalcode,inv.cmcompanyidfromdedupe.dbo.ln_invoice as invleft joindedupe.dbo.customerid as cidondbo.fnCleanString(inv.company) = cid.searchcowhere((inv.customerid is nulland cid.searchco is null)and (inv.date >= '01/01/2003' or (inv.date < '01/01/2003' andinv.outstanding > 0.01))and not inv.company is null)print 'Cursor declared'declare@contact varchar(75),@company varchar(50),@address1 varchar(75),@city varchar(30),@state varchar(20),@zip varchar(10),@cmcompanyid varchar(32),@iCount int,@FetchString varchar(512)open cInvprint 'cursor opened'fetch cInv into@company,@contact,@address1,@city,@state,@zip,@cmc ompanyidprint 'Cursor fetched @@Cursor_rows = ' + cast(@@cursor_rows asvarchar(5))All the prints are there to help me figure out what's going on!When I get to the Print 'Cursor fetched @@cursor_rows....the value is 0 and the script skips down to the close and deallocate.BUT, if I just highlight the Select...When section, I get over 2,000rows. What am I missing?Thanks.
View 6 Replies
View Related
Jul 23, 2007
What is the C# code I use to do this?
I'm guessing it should be fairly simple, as there is only one row selected. I just need to pull out a specific field from that row and then insert that value into a different SqlDataSource.
View 7 Replies
View Related
Feb 14, 2002
Can anybody help ?
I need to get a limited set of records from sorted record set. For example, I have a table called Contacts which contains about 2000 records and I need to show records from 11 to 20 in the sorted order.
In Oracle I could use this query.
SELECT name FROM
(SELECT name, ROWNUM rnum from Contacts order by Name)
WHERE rnum between 11 and 20
Is anything equivalent available in SQL Server ? My need is to show
records page by page ( as in google/yahoo search ) in my asp page.
Thanks
Subhash
View 1 Replies
View Related
Nov 13, 2000
Does anybody know how to get at the value set by a SET ROWCOUNT statement from within a Stored Procedure. e.g. If I executed the following:-
SET ROWCOUNT 50
EXEC Proc1
How could Proc1 find out that the User had done a SET ROWCOUNT 50.
Any ideas would be appreciated
View 1 Replies
View Related
Feb 8, 2001
Can @@rowcount be used with a regular select statement?
Thanks,
Ninel
View 2 Replies
View Related
Aug 15, 2002
Can someone send me the script that counts the rows of the table within
a database?
Thanks,
Dianne
View 3 Replies
View Related
Jul 25, 2005
Is Set RowCount @RowCountMore efficient than simply using TOP?Thanks for any input.
View 5 Replies
View Related
May 20, 2006
i'm trying to get total rows found by query that uses top clause...for example:select top 10 myTable.* from myTable where myTable.number > 200let's say there are 13 rows matching that condition, and by using@@rowcount my result would be: 10.is there any way to get total row count, without affecting the TOPclause??? i believe that the mysql equivalent would beSQL_CALC_FOUND_ROWS().tnx...
View 1 Replies
View Related
Sep 7, 2006
I'm writing an INSERT, UPDATE and DELETE trigger on table A that needs to insert rows into a table B.
When a user issues a "SET ROWCOUNT" command to limit the number of rows, then does an insert, update or delete, the trigger is being limited to that number.
It is important that the trigger NOT be limited to ANY specific number of records, but it is undesireable for me to just wipe out the current "SET ROWCOUNT" setting for the user without their knowledge.
How do I get and preserve the current "SET ROWCOUNT" value from within my trigger, so I can cancel the limitation and then re-implement the setting once my work is done? I cannot find any documentation specifying where the ROWCOUNT value is set (I initially thought maybe the SYSPROCESSES table, but that doesn't seem to be it).
Example:
set rowcount 1
update TABLEA set val=val+1
<the TABLEA trigger fires, trying to insert multiple rows into TABLEB but is limited to a single row>
Ideas?
View 1 Replies
View Related
Sep 5, 2007
Hi,
I am using ssis to import .csv files into sql server tables.
How do I get the count of the records imported?
Thanks
View 3 Replies
View Related
Jun 26, 2006
Hi,
want to get the number of rows i'm retrieving from a source. This count should be written as " No: of roes retrieved" + varname
I have used OleDbSource, RowCount,Script [ To write in a file ]. Rows is the package level variable name used in rowcount. when i do this way it always writes as 0 in the file.
[code in Script]
Dim sw As New StreamWriter("D:Vijay1.txt")
s = Variables.Rows
sw.WriteLine(s.ToString)
sw.close
[/Code]
Can anyone help on this
View 12 Replies
View Related
Dec 17, 2007
I have a data flow task which contains an XML Source, The XML Source puts data into two OLEDB Destination tasks. What i need to do is check that the number of rows inserted in to the two data bases . Can anyone suggest the easiest way as i need to check before i can commit the transactions. Any help would be most appriciated
Thanks
View 1 Replies
View Related
Aug 29, 2006
Hi, from what I can find, there isn't a way to get the number of rows returned from a SQLDataReader command. Is this correct? If so, is there a way around this? My SQLDataReader command is as follows:Dim commandInd As New System.Data.OleDb.OleDbDataAdapter(strQueryCombined, connInd)Dim commandSQL As New SqlCommand("GetAssetList2", connStringSQL)Dim resultDS As New Data.DataSet()'// Fill the dataset with valuescommandInd.Fill(resultDS)'// Get the XML values of the dataset to send to SQL server and run a new queryDim strXML As String = resultDS.GetXml()Dim xmlFileList As SqlParameterDim strContainsClause As SqlParameter'// Create and execute the search against SQL ServerconnStringSQL.Open()commandSQL.CommandType = Data.CommandType.StoredProcedurecommandSQL.Parameters.Add("@xmlFileList", Data.SqlDbType.VarChar, 1000).Value = strXMLcommandSQL.Parameters.Add("@strContainsClause", Data.SqlDbType.VarChar, 1000).Value = strContainsConstructDim sqlReaderSource As SqlDataReader = commandSQL.ExecuteReader()results.DataSource = sqlReaderSourceresults.DataBind()connStringSQL.Close()And the stored procedure is such:DROP PROC dbo.GetAssetList2;GOCREATE PROC dbo.GetAssetList2(@xmlFileList varchar(1000),@strContainsClause varchar(1000))ASBEGINSET NOCOUNT ONDECLARE @intDocHandle intEXEC sp_xml_preparedocument @intDocHandle OUTPUT, @xmlFileListSELECT DISTINCTAssetsMaster.AssetMasterUID,SupportedFiles.AssetPath,FROM AssetsMaster, OPENXML (@intDocHandle, '/NewDataSet/Table',2) WITH (FILENAME varchar(256)) AS x,SupportedFilesWHEREAssetsMaster.AssetFileName = x.FILENAMEAND AssetsMaster.Extension = SupportedFiles.Extension UNIONSELECT DISTINCTAssetsMaster.AssetMasterUID,SupportedFiles.AssetPath,FROM AssetsMaster, OPENXML (@intDocHandle, '/NewDataSet/Table',2) WITH (FILENAME varchar(256)) AS x,SupportedFilesWHEREAssetsMaster.AssetFileName <> x.FILENAMEAND CONTAINS ((Description, Keywords), @strContainsClause)AND AssetsMaster.Extension = SupportedFiles.ExtensionORDER BY AssetsMaster.Downloads DESCEXEC sp_xml_removedocument @intDocHandle ENDGOHow can I access the number of rows returned by this stored procedure?Thanks,James
View 3 Replies
View Related
Aug 16, 2007
Hi guys, can anybody help to solve this problem.
set @count=0Insert into User_t (userid, counter) select userid, count+1 from resultset is not working
0/p: bhasker 1 bhanu 1 kishore 1
but o/p must be bhasker 1 bhanu 2 kishore 3
View 5 Replies
View Related
Nov 17, 2007
Hi all
whether using TOP clause in SELECT statement or [SET ROWCOUNT n] before SELECT statement, I want to know how SqlServer Behave?
whether Fetching data and then choosing n record of them or as soon as fetching n records , Sql Server Stops retrieving the rest of the data?
Thanks in advance.
Regards.
View 1 Replies
View Related
Jun 16, 2004
Hello again everyone.....
Ok here's my problem.... This is definetly the strangest problem Ive had yet in my coding career..... anyways here it is:
I have a stored procedure which keeps a total number of hits for specific pages:
Procedure CMRC_Hits_Pages_Temp_Update
@Transaction nvarchar(20),
@Hits int = NULL,
@Page nvarchar(50) = NULL
AS
IF @Transaction = 'Delete'
BEGIN
DELETE FROM CMRC_Hits_Pages_Temp
END
IF @Transaction = 'Add'
BEGIN
CREATE TABLE #TempTableUpdate
(
Hits int
)
INSERT INTO #TempTableUpdate
(
Hits
)
SELECT
Hits
FROM
CMRC_Hits_Pages_Details
WHERE
Page = @Page
SELECT
Hits
FROM
#TempTableUpdate
IF @@Rowcount > 0
BEGIN
UPDATE CMRC_Hits_Pages_Temp
SET
Hits = Hits + @Hits
WHERE
Page = @Page
END
IF @@Rowcount < 1
BEGIN
INSERT INTO CMRC_Hits_Pages_Temp
(
Hits,
Page
)
VALUES
(
@Hits,
@Page
)
END
END
I've written it so if there hasn't been an entry for @Page, make a new one..... And if there is an entry allready for @Page, add @Hits to Hits.
Here's the strange part. When I run it in Query Analyzer (so I know there isn't a problem with my pages code), it works fine when I send @Page a value of 'Default' (As in my default page). But when I put any other value (ei. 'ProductsList', ProductDetails', 'test', 'Defauls') it doesn't work. It creates a new record even if there was a record for that page allready. I've tried erasing everything from the table over and over to give it a fresh start and it still only works for 'Default.'
I've tried every length of string possible thinking it may be the length, same problem.
It makes no sense to me why specific letters could make any difference in what this procedure does. A string is a string, right? Why should one string be more recognizable than another? Again, the most confusing thing I've enountered yet in my coding career.
I seem to always run into problems and think "this makes no sense" and then come to figure "Ohhh.... thats whats wrong..." But this problem here is definetely the cream.... It makes NO sense.....
Thank you to whomever can solve this mystery..... (If it is much of one....)
Just incase the Table info is important:
I have two Columns: Hits, int (4) & Page, nvarchar (50)
-Alec
View 2 Replies
View Related
Nov 1, 2005
Hi,I am just starting sql and have a stored proc which does a simple select and should return 2 when no rows match the selection criteria . The problem is that it always returns 2, even where there are rows which match the selection criteria and when there are no rows.CREATE PROCEDURE dbo.SelectSomething @a INT, @b INTAS SET NOCOUNT ON SELECT a, b, c, d FROM dbo.SomeTable WITH (READUNCOMMITTED) WHERE a = @a AND b = @b IF @@ERROR<>0 RETURN 1 IF @@ROWCOUNT=0 RETURN 2 -- Always Returns 2RETURN 0GOThanks for any help.
View 2 Replies
View Related
Jan 11, 2006
I was testing some checking techniques to add to my SPs while retreiving data or inserting a series of reocords to a series of tables.
Check this testing small piece of code:begin transaction t1
select * from roles where rolename = 'student'
if @@rowcount = 0
goto cleanup
select * from users
if @@rowcount = 0
goto cleanup
commit transaction t1
goto endup
cleanup:
rollback transaction t1
SET ROWCOUNT 0
endup:
print @@rowcount
On one of the testing cases: I made the first query return 1 record and the second returned 5 records, so we ended up at the label "endup", I printed out the RowCount it was 0, does the commit transaction reset that variable?
In addition, are there smart and effective techniques to check against validity of the query statements inside the SP, for example, I can use @@ERROR and @@ROWCOUNT in a transaction based SP to know if I proceed with sub queries, are there more stuff like that?
Regards
View 5 Replies
View Related
Mar 26, 2001
I want to create a stored procedure where I pass the name of a view, the number of rows in the view is determined. If the number of rows is zero, I want the sp to fail with an error code that would bring the DTS that executed the sp down. Here is the sp so far. Note that I am EXECuting a sql string because the FROM clause cannot accept a passed variable. Problem is I need the value of my counter variable(@resultcount) to be available after the EXEC statement. Any ideas on how to do this?
CREATE PROCEDURE CheckForEmpty
@tablename varchar(50)
AS
declare @resultcount integer
declare @sSql varchar(255)
--SP to check for rowcount in passed table name. Useful in DTS steps to stop load process if no rows in sending table.
set @sSql = 'set @resultcount = (select count(*) from ' + @tablename + ')'
exec (@sSql)
if @resultcount = 0 RETURN(-99) else return(0)
View 1 Replies
View Related
Aug 17, 2000
I am trying to put the result of the number of lines of data transferred, in a mail message. In a query, i get the result but i am having trouble displaying the result in xp_sendmail. Any help and/or code will be appreciated.
Thanks
View 2 Replies
View Related
Aug 2, 2002
Is there a script someone knows of which could give me the rowcounts of all the tables in a database?
thanks a lot!
View 2 Replies
View Related
Jul 2, 2004
Can someone throw light on how to get the rowcount of a table that is stored in any system tables? I want to get tablename and rowcount for all user tables in a database in a query. Is there anyway other than count(*)?
Thanks
Vinnie
View 10 Replies
View Related
Jan 21, 2005
I have an sp that returns data to a client application. I wonder how I'd go about doing the following: I need to implement a maximum amount of rows on a combination of several columns that are part of the resultset.
fe; Col001, Col002, Col003 are the result, the unique count of Col001 and Col002 are two;
Col001, Col002, Col003
1, 'aa', 'someOtherValue'
1, 'aa', 'someThingElse'
1, 'aa', 'ratherSillyActually'
2, 'aa', '...'
I'd return:
1, 'aa', 'someOtherValue'
1, 'aa', 'someThingElse'
2, 'aa', '...'
Any idea's?
View 14 Replies
View Related
Mar 9, 2004
Hi I'm opening a RecordSet using the following code :
declare tcrl cursor FAST_FORWARD for SELECT TSample.ISmpCode
FROM TCertResults TSample
WHERE (TSample.ISmpShortCode ='24/12359')
Open trcl
What I want to be able to get a count of this recordset. Been thru the TSQL help and it's pointing me toward the @@RowCount command but I can't seem to get this working.
Any help would be apprieciated
View 14 Replies
View Related
Mar 31, 2006
Hi,
I ran the following code and got @rows to display the value 1 - I guess it should display 0 because the IF statement returns no rows of course - So why is it displaying 1?
DECLARE @ERRORS INT
SELECT 5,10,15
IF @@ERROR > 0
SET @ERRORS=1
ELSE
SET @ERRORS=0
SELECT 'ROW_Count', @@ROWCOUNT --> shows 1 !!
View 3 Replies
View Related
Sep 5, 2007
Trying to get the rowcount, rowsize for every table in everydatabase?
I'm getting the same tables from the same db. anyone ideas how to fix it?
declare @db varchar(40)
declare @sql varchar(8000)
declare @cursor varchar(8000)
declare @table_name varchar(60)
declare a cursor for
select name from master..sysdatabases
open a
fetch a into @db
while @@fetch_status = 0
begin
print ''
set @sql = 'use [' + @db + ']'
print @sql
exec (@sql)
declare b cursor for
select table_name from information_schema.tables
where table_type = 'base table'
and table_schema = 'dbo'
and table_name not like 'dbo.%'
open b
fetch next from b into @table_name
while @@fetch_status = 0
begin
select @cursor = 'exec sp_spaceused ' + '[' + @table_name + ']'
print @cursor
-- exec (@cursor)
fetch next from b into @table_name
end
close b
deallocate b
fetch next from a into @db
end
close a
deallocate a
=============================
http://www.sqlserverstudy.com
View 1 Replies
View Related
May 4, 2006
I am trying to work a statement like the below - but am getting an error - I assume that @@ROWCOUNT is not supported?
UPDATE MobileInvoiceImport SET OrderDetailID = '123', QuantityReceived = '66' WHERE OrderDetailID = '123'
IF @@ROWCOUNT = 0
INSERT INTO MobileInvoiceImport (OrderDetailID, QuantityReceived) VALUES('123','1')
View 1 Replies
View Related