DataSource Controls :: Return Number Of Rows Affected For Multiple Queries In One SQLCommand?

Feb 22, 2010

I am accepting query/queries from user (our support team) in a text box where user can enter only one query or multiple queries. I need to display result of all queries entered in the textbox. If it is SELECT statement then result of that statement in grid which is done. If UPDATE/INSERT/DELETE then total number of rows affected which is also done but if only one UPDATE/INSERT/DELETE statement is entered in the textbox.

If user enters 2 UPDATE statements and then a SELECT statement then how can I get number of rows affected for individual UPDATE statements just like SQL Server Qury Analyzer displays messages in its result pane.


(6 row(s) affected) -- first UPDATE statement

(4 row(s) affected) -- second UPDATE statement

(16 row(s) affected) -- for SELECT statement (grid will also be displayed along with these messages).

I tried almost everything, SqlDataSource (returns count of first statement only), SqlCommand.ExecuteNonQuery and DataAdapter.Fill (returns count of last statement only).

View 3 Replies

Similar Messages:

DataSource Controls :: LINQ To SQL - Multiple Queries Doesn't Return Any Results

May 25, 2010

I am working on 3.5 and in MVC using Linq to SQL classes. In my MVC project i am calling stored procedure using linq to sql that conatin query joining two tables.Below is my code in Partial class

IMultipleResults GetUserWiseThreadDetail_SP([Parameter(DbType="VarChar(30)")]
string userID)
ExecuteResult result = this.ExecuteMethodCall(this,
(MethodInfo)(MethodInfo.GetCurrentMethod())), userID);
return ((IMultipleResults)(result.ReturnValue));

In one of the controller i have made one more class

public class
IEnumerable<Thread> Thrds {
set; }
IEnumerable<Reply> Repls {
set; }
public MypostIndexData(IEnumerable<Thread>
thrds,IEnumerable<Reply> repls)

finally coding of controller action method

ForumDataContext pmforum = new
ActionResult MyPosts(string userId)
IMultipleResults result = pmforum.GetUserWiseThreadDetail_SP(userId); (this satement doesnot give any result,if i execute stored proc in
sql it give the results)
thrds = result.GetResult<Thread>();
List<Thread> thrdlist =
repls = result.GetResult<Reply>();
List<Reply> replylist;
if (repls !=
replylist = new
return View(new

I am unable to understand why i am not getting any results?

View 5 Replies

DataSource Controls :: SQL Query Return Incorrect Number Of Rows?

Mar 29, 2010

I am working on a small project. I ran the query below to get the maximum userid and increase it by 1 to create a new userid. However, when I run the query, it does not display the values that I enter into the database using insert statement. For example, if I open the table called login, I can see there are three records. If Irun the select statement, it only return one record which is the one that I enter manually when I first created the table. If I run the same select statement and give it a user id that I created, it returns the correct result.


View 2 Replies

ADO.NET :: Get Number Of Rows Affected By Using Procedure In Linq?

Dec 18, 2010

i have create the object of

1 dataclassContext obj=new dataclassContext();

2 now i call the updateProc

int row=ob.MyupdateProc(QuestionID,peronID);
do some thing

but row always retrun 0 even procdure do update in database

View 1 Replies

How To Enforce A Certain Number Or Range Of Affected Rows In SQL Server Or C#

Feb 17, 2011

for some SQL queries I know the expected number of rows that must be affected by UPDATE, DELETE or INSERT statements. It could be a number such as 1 or a range such as 0-1 or 1-2 etc.

What is the best way to enforce that this is the number of affected rows and that otherwise an exception is thrown?

Also, can I limit the number of rows affected for UPDATE/DELETE/INSERT to say 1 row and otherwise get an exception?

View 4 Replies

DataSource Controls :: Filter A DataView To Return All The Rows Whose Column X Starts With A Number

Jan 29, 2010

I'm trying to filter a DataView to return all the rows whose column x starts with a number: The following works in SQL Server:

select *
from dbo.Page
where Name like '[0-9]%'

However, when I try this:

dataView = new DataView( someDataTable, "Name LIKE '[0-9]%'", "Name ASC", DataViewRowState.CurrentRows);

I get "invalid parameter [0-9] with Operator Like" error message. What is the correct syntax to achieve my goal?

View 7 Replies

DataSource Controls :: Can Capture Return Value From A SQL By Using SqlConnection SqlCommand

Apr 15, 2010

can capture return value from a SQL by using SqlConnection SqlCommand


View 3 Replies

DataSource Controls :: How To Check Two Queries Return Result Is Same

Feb 26, 2010

how to wrote stored procedure for check two queries result this result is same return true value its not same return false value

View 2 Replies

DataSource Controls :: Table / Database Design Theory - Return Faster Queries

Feb 5, 2010

In general terms, which way will require more server processing power and which way will return faster queries... if there is even a difference. The client's database is still on the dev MS SQL server but is essentially but the client has decided they want to collect two more fields of information. Both fields are going to be collection text data and probably varchar(300) will be sufficient for the column data types. Would it ultimately be more efficient to

Add two additional columns in the main table so the data is entered directly into each record, or Add an additional table (or two) with a foriegn key to the primary table that holds the info for each new field The SELECT statement for the main table could be modified to either add the new columns (a.NewColumn1 and a.NewColumn2) or it could contain nested SELECT statements that pull in the data from the other tables. Custom daisy-chained Insert or Update statements would be no problem and a cascade Delete relationship would take care of any deletions. I'm just trying to figure out which would be better from a performance standpoint?

View 3 Replies

Forms Data Controls :: Return Number Of Rows In A Dataset?

Jan 14, 2010

I'm using a table adapter to perform my queries. I'm sure I'm missing something really easy, but I can't figure out how to return the number of rows returned from a query to a dataset used for a GridView.Basically, I want to display a message "No records exist for your selection" by testing for ReturnedRows = 0.

Excerpt of C# code:

handoutDSTableAdapters.handoutTableAdapter handoutsAdapter =
new handoutDSTableAdapters.handoutTableAdapter();
gv_Handout.DataSource = handoutsAdapter.GetDataByDoctor(Int32.Parse(ddl_MD.SelectedValue));

View 4 Replies

Forms Data Controls :: How To Return Multiple Rows From A Query

May 18, 2010

I have the below c# method to populate an frontend control from a linq query. The only valid way I seem to be able to reference the query variable "result" is if I use the attribute "SingleOrDefault" but unfortunately this forces my query to return just the one single set of data for every unique primary key UserId value from my query, where I require the unique data attached to each different UserId value to be returned, how can I achieve this using linq? Note, I am passing the UserId value into my method from a public variable which is also below.


View 4 Replies

DataSource Controls :: Return Unique Rows : T-SQL Query

Jun 11, 2010

I have an SQL database table like the following:

ID // Code // Shape

The ID is the integer identifier.

On one line the Code may be OX01 and shape Hexagon for example

Then the next line the code is still OX01 but the shape is Triangle.

What I want to do is be able to pull back data for every line that is equal to a unique Code column. in the above example OX01 Hexagon would be returned but not OX01 Triangle.

I've tried using SELECT DISTINCT but it brings back all records and doesn't filter them correctly.

I've considered having another column which could have Child/Parent data so that only the parent is returned but i'm sure there must be a better way of doing this.

View 2 Replies

DataSource Controls :: How To Count Number Of Rows In Database

Jan 8, 2010

i am using sql 2005 db. i have created a table called attendance where i store employee attendance, i want to separate number of absence for a particular employee and particular month. It have to show number of absence of a particular employee and particular month. Also i have to count no of absence. for eg: if an employee absence for two days for a particular month, it have to display 2 count.. how to do this? also how to write the store procedure for this?

View 4 Replies

DataSource Controls :: Count The Number Of Rows Returned From The Database?

Jan 17, 2010

I have executed my query in VB with:


I now want to count the number of returned rows so that I can say:IF rows_returned = 1 then login else deny
I think you get the idea.P.S. I know this is not the most secure method of login but I do not want to use the ASP.NET configuration manager as I like to understand what is happening. I am starting off very simple and I shall work up from there.

View 1 Replies

DataSource Controls :: SQL Select Union And Total Number Of Returned Rows?

May 1, 2010

SQL Select Union and total number of returned rows?

View 3 Replies

C# - Web Service - Return Multiple Rows?

Dec 5, 2010

I have a web service method which i'd like to return multiple rows from a datatable.

I am familar with returning values from web service methods but not multiple rows from a datatable. What is the best way to go about doing this? Do I need to return an array or list<>?

My code method is setup like this.

public void UpdateBold(int count, float lat, float lng)
DataTable dt = new Gallery().DisplayNearestByLatLong(count, lat, lng);
// return code here

View 2 Replies

Forms Data Controls :: Adding Specific Number Of Blank Rows After Binding Gridview With Datasource

Jan 29, 2011

i hav a gridview ... now i need to add certain number of rows... say 5 rows .... which would b blank .. the rows consist of itemtemplate of textboxes.. here is the grid ...


now i am binding this gridview with certain data say :


now the problem is if the row contains 2 data originally ... then it alwz shows up with only two rows with binded data... but what i want is 2 (databinded rows ) + 5 (empty rows with textbox ) = 7 grid view rows .... now how to do it ... after i hav binded the textbox with data already....with some empty columns corresponding to the above code ?

View 5 Replies

DataSource Controls :: Return Multiple Values From Stored Procedure?

Jun 2, 2010

Is it possible to return multiple values from a stored procedure? Basically, if I execute the stored proc on the C# side, then on the SQL side I do multiple calculations. Let's say I have 5 int values I need returned to the C# side.

View 4 Replies

DataSource Controls :: Inline T-SQL Syntax To Return Multiple Data Fields?

Mar 16, 2010

I have a method in my button code to run the query, it returns a value and save it to a Session variable to be used later, this code works.Dim connString As String = ConfigurationManager.ConnectionStrings("DBConnectionString").ConnectionStringUsing myConnection As New SqlConnection(connString)

Const sql As String = "SELECT Rate1 FROM Rates WHERE (LayerID = '01')"
Dim myCommand As New SqlCommand(sql, myConnection)


View 4 Replies

DataSource Controls :: Summing A Column From Multiple Rows?

Jul 1, 2010

I currently have a datasource that displays several rows on an editable gridview where the user can update several rows at once. Each row contains an ActivityTotal column per row. I'd like to sum all the ActivityTotal rows displayed and have one totalValue.

for example

row 1 activityTotal = 4
row 2 activityTotal = 3
row 3 activityTotal = 1
totalValue = 8

How can I incorporate this into the code?

View 7 Replies

Find Out If There Is Any Rows In SQLCommand Query?

Nov 9, 2010

I have some code like this

Dim conn As SqlConnection = New SqlConnection("server='h'; user id='w'; password='w'; database='w'; pooling='false'")
Dim query As New SqlCommand("DECLARE @investor varchar(10), @sql varchar(1000) Select @investor = 69836 select @sql = 'SELECT * FROM OPENQUERY(db,''SELECT * FROM table WHERE investor = ''''' + @investor + ''''''')' EXEC(@sql)", conn)
dgBookings.DataSource = query.ExecuteReader

I need to add in an If statement basically saying if the SQLCommand query returns no rows then show a specific label Can this be done?

View 2 Replies

DataSource Controls :: Use ArrayList In SqlCommand

May 1, 2010

I want to add array list in sqlcommand.but i don't no how to pass it. My code is.

ProductId = new
for (int i = 0; i < ShipmentPackage.Items.Count; i++)
select * from TableName where id= ProductId(ProductId is my Arraylist)

View 3 Replies

Forms Data Controls :: Getting Number Of Queries By The Categoryid

Feb 15, 2011

've made a quiz/score system where a user will go through categories (page by page using querystring) and after submitting his/her score i redirect them to the next page where i show them their score and i also want to show "out of x number of questions".

I've made a query in my dataset:


I get an error about "Cannot implicitly convert type "void" to "object". This is the first time i am trying to use the SQL COUNT so i am almost certain it has something with the way i write it in my BLL, but i cannot figure out why or how to write it as it should. Hopefully you can direct me in the right path?

View 5 Replies

DataSource Controls :: How To Return Multiple Output Parameter From Sql Server Stored Procedure

May 5, 2010

i want to return two output parameter n temp table from sql server stored procedure

View 6 Replies

DataSource Controls :: How To Save Multiple Rows Using ADO.NET Entity Framework

Mar 23, 2010

public void saveOptionalCourses( ArrayList coursesAdded, int studentID)
StudentOptionalCoursesXRef XRefObject = new StudentOptionalCoursesXRef();
using (var EntityObject = new SchoolProjectEntities2())
foreach ( string list in coursesAdded)
XRefObject.StudentDetails = EntityObject.StudentDetails.Where(c => c.StudentID == studentID).First();
XRefObject.OptionalCourses = EntityObject.OptionalCourses.Where(c => c.OptionalCourseName == list).FirstOrDefault();

with this above method and could save only last row that am returning remaining rows are iterated but are not saving on to database

View 2 Replies

Copyrights 2005-15, All rights reserved