AffectedRows Different From ObjectDataSource Then SqlDataSource
May 27, 2008
I have a gridview control that accesses either an objectdatasource or a sqldatasource
both of which excute "select * from customers"
the affected-rows property when using the sqldatasource is always the number of rows returned (what I want)
but i need to use an object data source to access a table-adapter
when using the ODS affectedrows is always -1 no matter how mayn rows were returned
why is this
is there another way to get the number of records returned by an ODS
View 1 Replies
ADVERTISEMENT
Jan 16, 2006
I have an SQLDataSource that I would like to filter out some records that are stored in an ObjectDataSource. Is this possible? The data that is filling the ObjectDataSource is being populated by a WebService.
SQL in SQLDataSource----------------------------
SELECT id, accountFROM contactWHERE id NOT IN (SELECT id FROM ObjectDataSource.Records...)
Thanks.
View 1 Replies
View Related
Mar 5, 2007
Hi
Using ASP.NET 2.0, Sql Server 2005.
I have a simple page (NOT a formview) with some entries textbox's , checkbox and dropdownlistbox's
I want to link a datasource to the 'Item Page' and bind the datasource's values to the page
The select statement is
Select a.IssueID,
a.ProjectID,
a.VersionID,
a.toincludeversionid,
a.Version,
a.toincludeversion,
a.TypeofEntryID,
a.PriorityID,
a.WorkFlowID,
a.Title,
a.Area,
a.Details,
a.Question,
a.Answer,
a.HowToRepro,
a.DevelopersNotes,
a.TestersNotes,
b.ProjectID,
b.ProjectName,
OldVersion.Version,
ToIncludeVersion.Version,
d.DESCRIPTION,
e.DESCRIPTION,
x.TaskID as TaskID,
x.DESCRIPTION as TaskDescription,
z.Taskdone,
CONVERT (char(9),z.TaskAssignedDate, 3) AS Workflowdate,
z.StaffID as StaffID,
w.username,
y.latest_workflowid
from issue as a
Inner join ProjS b on b.ProjectId=a.ProjectID
Left Outer join Version OldVersion on a.VersionID=OldVersion.VersionID
Left Outer join Version ToIncludeVersion on a.VersionID= ToIncludeVersion.VersionID
Inner join TypeOfEntry d on d.TypeOfEntryID=a.TypeofEntryID
Inner join Priority e on e.PriorityID=a.PriorityID
inner join workflow z on z.issueid=a.issueid
Inner join (select issueid,max(workflowid) as latest_workflowid from workflow group by issueid) y on y.latest_workflowid=z.workflowid
Inner join task x on x.taskid=z.taskid
Inner join staffls w on w.StaffID=z.StaffID
Where a.IssueID= @IssueID
I hope I have made query clear, if not I don't mind explaining more.
Thanks in advance
View 1 Replies
View Related
Jan 9, 2007
Stored Procedure:CREATE PROCEDURE [dbo].[GetBanner] @BannerPage nvarchar(50), @MagazineID intASBEGIN SET NOCOUNT ON; DECLARE @BannerID int SELECT TOP 1 @BannerID = BannerID FROM Banners WHERE BannerPage=@BannerPage AND MagazineID = @MagazineID AND StartDate <= GetDate() AND EndDate >=GetDate() ORDER BY Views SELECT BannerID, BannerFileName, AltText, URL, Views FROM Banners WHERE BannerID = @BannerID UPDATE Banners SET Views = Views +1 WHERE BannerID = @BannerID UPDATE BannerStats SET Views = Views + 1 WHERE BannerID = @BannerIDEND OnSelected method: protected void dsBanner_Selected(object sender, SqlDataSourceStatusEventArgs e) { int RecordCount = e.AffectedRows; Response.Write(RecordCount); } This ALWAYS gives me 0 - despite the fact that the correct banner is pulled from the database, and updated etc. Also, when I execute the procedure (for valid parameter values) in SSMS, I get "1 row(s) Affected". Can anyone tell me what I need to change to get the proper value? Thanks
View 6 Replies
View Related
Nov 16, 2007
I'm confused about the e.AffectedRows documentation. The documentation says that e.AffectedRows is, "The number of rows affected by a database operation. The default value is -1."I am getting -1 returned after a successful update. Am I supposed to get -1 returned after a successful operation or a 1 because 1 row was affected by the update?
View 2 Replies
View Related
Jun 19, 2007
I'm trying to effecinty page through many rows of data with the gridview and objectdatasource. I'm having trouble. I'm using a table adapter with predefined counting and select methods. I have tested all the methods and they all work properly. But when I configure the object datasource to use the table adapter, and set the gridviews datasrouce, the page doesn't load and I wind up getting "time out". Any help? <asp:GridView ID="GridView1" runat="server" AllowPaging="True" DataSourceID="objTopics"> <Columns> <asp:BoundField DataField="topic_title" /> </Columns> <EmptyDataTemplate> <p>NOTHING HERE</p> </EmptyDataTemplate> </asp:GridView> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" EnablePaging="True" OldValuesParameterFormatString="original_{0}" SelectMethod="GetTopics" SelectCountMethod="GetTopicsRowCount" TypeName="TopicsTableAdapters.discussions_GetTopicsSubSetTableAdapter"> <SelectParameters> <asp:Parameter DefaultValue="1" Name="startRowIndex" Type="Int32" /> <asp:Parameter DefaultValue="10" Name="maximumRows" Type="Int32" /> <asp:Parameter DefaultValue="1" Name="board_id" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource>
View 1 Replies
View Related
Jun 21, 2007
I have a problem with efficiently paging with gridview and objectdatasoruce. I have GetPosts1(startRowIndex, maximumRow, topic_id) and GetPostsCount(topic_id). I tested each procedure and each are working correctly. The problem is with the controls. Here is the code for the controls. <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames DataSourceID="ObjectDataSource2"> <Columns> <asp:BoundField DataField="RowNumber" HeaderText="RowNumber" SortExpression="RowNumber" /> <asp:BoundField DataField="post_id" HeaderText="post_id" SortExpression="post_id" /> <asp:BoundField DataField="post_subject" HeaderText="post_subject" SortExpression="post_subject" /> <asp:BoundField DataField="post_text" HeaderText="post_text" SortExpression="post_text" /> <asp:BoundField DataField="post_time" HeaderText="post_time" SortExpression="post_time" /> <asp:BoundField DataField="topic_id" HeaderText="topic_id" SortExpression="topic_id" /> <asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" /> <asp:BoundField DataField="UserID" HeaderText="UserID" SortExpression="UserID" /> </Columns> </asp:GridView> <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" OldValuesParameterFormatString="original_{0}" EnablePaging="True" SelectMethod="GetPosts1" SelectCountMethod="GetPostsCount" TypeName="PostsTableAdapters.discussions_GetPostsTableAdapter"> <SelectParameters> <asp:QueryStringParameter DefaultValue="48" Name="topic_id" QueryStringField="t" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource> When I run the page, I get "A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll" and then "The thread '<No Name>' (0xbe0) has exited with code 0 (0x0)." Could the problem be with null or empty values in the returned data?
View 1 Replies
View Related
Dec 24, 2007
Hi,
I have been trying to get the scope Identity after inserting a record using an ObjectDataSource.
I can't find what event, or how to get the value that the scope identity returns.
Here is my Sproc.
ALTER PROCEDURE dbo.[YourCompany_LanCustomer_Insert]
(
@DNNUserID int,
@FirstName nvarchar(50),
@LastName nvarchar(50),
@Address nvarchar(50),
@Address2 nvarchar(50),
@City nvarchar(50),
@State nvarchar(50),
@Zip nvarchar(50),
@EmailAddress nvarchar(50),
@PhoneNumber nvarchar(50),
@CustomerID int OUTPUT
)
AS
INSERT INTO YourCompany_LanCustomer
(DNNUserID, FirstName, LastName, Address, Address2, City, State, Zip, EmailAddress, PhoneNumber, DateEntered)
VALUES (@DNNUserID, @FirstName, @LastName, @Address, @Address2, @City, @State, @Zip, @EmailAddress, @PhoneNumber, getdate())
SET @CustomerID = Scope_Identity()
RETURN
View 8 Replies
View Related
Mar 11, 2006
The function that is supposed to delete a row, is not working. The function is called, and the windows is refreshed, but the row is not deleted.Can anyone see anything wrong with this code:public static void DeleteBlog(int original_BlogID) { string insertCommand = "DELETE FROM Blog WHERE BlogID = @BlogID"; SqlConnection myConnection = new SqlConnection(Blog.ConnectionString); SqlCommand command = new SqlCommand(insertCommand, myConnection); command.Parameters.Add(new SqlParameter("@BlogID", original_BlogID)); myConnection.Open(); command.ExecuteNonQuery(); myConnection.Close();}
View 3 Replies
View Related
Nov 22, 2007
How can you use SQL Full Text Search CONTAINS() with an asp.net 2.0 ObjectDataSource using @Parameters?
MSDN says something like this, but only works directly using like the Query from SQL Manager:
USE TestingDB;GODECLARE @SearchWord NVARCHAR(30)SET @SearchWord = N'performance'SELECT TestTextFROM TestingTableWHERE CONTAINS(TestText, @SearchWord);
I tryed to mak something like that work with the DataSet DataAdapter Query Builder for the ObjectDataSource, but you can't use DECLARE or SET.
SELECT TestTextFROM TestingTableWHERE CONTAINS(TestText, @SearchWord);
But again it says @SearchWord not a valide SQL Construct
Is there anyway to make a DataSet.DataApater.ObjectDataSource work with an SQL FTS CONTAINS() with @Parameters?
View 6 Replies
View Related
Mar 10, 2008
I wrote a Scalar UDF in SQL2005 that returns an integer. I want to be able to display this integer in a ASP.Net 2.0 web page. I typically use a DAL for all data so I added an ObjectDataSource as a Qeury that contains only the UDF. How do I easily display the value in a Label Control or?
I have tried to use a Repeater with a label, a Formview with a Label, all to no avail. Any suggestions?
View 12 Replies
View Related
Apr 3, 2008
I got the following error when trying to pass a parameter from an ObjectDataSource to a BLL during the OnObjectCreated event:No parameterless constructor defined for this object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.The ObjectDataSource in the aspx is as follows:
<asp:ObjectDataSource ID="LoadData" runat="server" SelectMethod="GetData" TypeName="Export00.Export" OnObjectCreated="SrcObjectCreating"> </asp:ObjectDataSource>
The code behind in aspx.cs is as follows:
protected void SrcObjectCreating(object sender, ObjectDataSourceEventArgs e)
{ Export sqlcommand = new Export("SELECT [DocTitle], [DocID] FROM [Document]"); e.ObjectInstance = sqlcommand;
}
The BLL is as follows: Export.cs (this is the BLL)
namespace Export00{ public class Export { private readonly string connString; private readonly string sqlCommand;public Export(string command) { sqlCommand = command; connString = WebConfigurationManager.ConnectionStrings["MyConnString"].ConnectionString; } }
}Can someone tell me why am I getting this constructor error and how to resolve it? Thanks in advance.sg2000
View 3 Replies
View Related
Jun 2, 2008
I've been studying this tutorial over here at: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/data/databases.aspx#updatedelete
but I can't seem to get my gridview working. I want to be able to edit the fields and also delete an entire row from the table if needed.
I hard coded in the update and delete commands into my objectdatasource but I still get the error message. Also, I can't even refresh the aspx page:
<%@ Page Language="VB" MasterPageFile="~/templates/admin.master" AutoEventWireup="false" CodeFile="article_comments.aspx.vb" Inherits="admin_Default2" title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="PageHeading" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PageContents" Runat="Server">
`<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" Width="536px" DataKeyNames="ratingID">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="ratingID" HeaderText="ratingID" InsertVisible="False"
ReadOnly="True" SortExpression="ratingID" />
<asp:BoundField DataField="rating" HeaderText="rating" SortExpression="rating" />
<asp:BoundField DataField="ip" HeaderText="ip" SortExpression="ip" />
<asp:BoundField DataField="itemID" HeaderText="itemID" SortExpression="itemID" />
<asp:BoundField DataField="comment" HeaderText="comment" SortExpression="comment" />
<asp:CheckBoxField DataField="active" HeaderText="active" SortExpression="active" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetRatings" TypeName="articlesTableAdapters.tblArticleRatingTableAdapter" DataObjectTypeName="articles+tblArticleRatingDataTable" DeleteMethod="DELETE FROM [tblArticleRating] WHERE [ratingID] = @ratingID" UpdateMethod="UPDATE [tblArticleRating] SET [ratingID] = @ratingID, [rating] = @rating, [ip] = @ip, [itemID] = @itemID, [comment] = @comment WHERE [ratingID] = @ratingID">
<UpdateParameters>
<asp:Parameter Name="dataTable" Type="Object" />
<asp:Parameter Name="itemID" Type="Int32" />
</UpdateParameters></asp:ObjectDataSource>
</asp:Content>
>
View 4 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
Mar 8, 2007
i am using visual web developer 2005 with SQL Express 2005 with VB as the code behindi have one database and three tables in itfor manipulating each table i am using separate SqlDataSource() is it sufficient to use one SqlDataSource() for manipulating all the three tables ? i am manipulating all the tables in the same page only please help me
View 1 Replies
View Related
Aug 20, 2006
I have an asp:sqldatasource which is bound to a gridviewIn addition to this I would like it to a) see if there is a specif row/ item in it (ie item_id = 10 for any of the rows it has received) as I conditionally want to show another item outside of the gridview subject to if it is in the gridview or notb) show the sum of all the values within a certain column of returned rowsMany thanks
View 1 Replies
View Related
Oct 11, 2006
How do I get the result of this select into a variableDim sqldsFindUserId As SqlDataSource = New SqlDataSource sqldsFindUserId.ConnectionString = ConfigurationManager.ConnectionStrings("bluConnectionString2").ToString sqldsFindUserId.SelectCommandType = SqlDataSourceCommandType.Text Dim myUserIdCmd As String = "select pkUser from tblUsers where strDisplayName='" + myDisplayname + "" sqldsFindUserId.SelectCommand = myUserIdCmd ' The result of this select statement is to be stored in a variable, how do I do it?
View 2 Replies
View Related
Jan 15, 2007
hi all,
in all my 2.0 learnings and books i keep coming across the page element <asp:sqldatasource>.
I have always (in 1.1) used server side connections and adapters to bind my Sql datasets to any control needed. Now that im learning 2.0 im finding it difficult to understand using control on the page to bind my data. Can someone explain the benefits of using this data source? Ideally i would like to keep my data access layer separate from my presentation layer but i'd really like to understand why this method seems so popular.
thanks in advance,
mcm
View 2 Replies
View Related
Feb 23, 2007
Hi, I am new to ASP.NET 2.0 and I am trying to use VWB to bind my web site to a SQL Express edition. I used SQLDataSource to specify the .mdf file so I can connect to my tables but when I click on the advanced button to generate the Insert, Update, Delete SQL I find it grayed out and it cannot be clicked. I looked into several tutorials online and I couldn't find the problem, can anyone explain what I am missing or doing wrong? Any suggestion is very appreciated. Thanks
View 2 Replies
View Related
Mar 30, 2007
SELECT * FROM [CONTACTS] WHERE @ddl_value LIKE '%@txt_value%'
Why doesn't this not working
I am using SQLdatasource control to bind a gridview
If my query is wrong then what might be the correct one to work with like operator in the sqldatasource
Can any ony help me!
View 4 Replies
View Related
Apr 12, 2007
Hello All,
I have quick question ..
In my aspx page i have gridview and Sql DataSource object as you can see
<asp:sqldatasource id="SqlDataSource1" runat="server" ></asp:sqldatasource>
<asp:gridview id="GridView1" runat="server" allowpaging="True" allowsorting="True" autogeneratecolumns="False" datasourceid="SqlDataSource1">
<columns>
<asp:boundfield datafield="breakdownid" headertext="breakdownid" insertvisible="False"
readonly="True" sortexpression="breakdownid" />
<asp:boundfield datafield="ticketno" headertext="ticketno" sortexpression="ticketno" />
<asp:boundfield datafield="systemtype" headertext="systemtype" sortexpression="systemtype" />
<asp:boundfield datafield="break_date" headertext="break_date" readonly="True" sortexpression="break_date" />
<asp:boundfield datafield="subject" headertext="subject" sortexpression="subject" />
<asp:boundfield datafield="status" headertext="status" sortexpression="status" />
<asp:boundfield datafield="prioritylevel" headertext="prioritylevel" sortexpression="prioritylevel" />
<asp:boundfield datafield="mobiletype" headertext="mobiletype" sortexpression="mobiletype" />
</columns>
</asp:gridview>
In codebehind file i call a function to get data from database. what i want is to bind the result to the sqlDataSourse not the gridview.
I need to have the SqlDataSourse thier.. Any help please
Sub Page_load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim objReader As New Dynamic.Reportsdemo
SqlDataSource1 = .objReader.Get_Tickets(1, 0, "all")
SqlDataSource1.DataBind()
objReader.objconnection.Close()
End If
End Sub
Thanks.
View 1 Replies
View Related
May 28, 2007
Hi!Please tell me, how to get a simple value using SQLDataSource, I mean a number, or char, or string - any value, NOT DataTable
View 3 Replies
View Related
Jul 23, 2007
I am trying to get record from a table and verify it with a textbox i have a sqldatasource.
i have a text box called txtEmail and this is my Select command. how can i get this working if its possible ?
something like txtEmail.text = SqlDataSource1.Secect then ... my code. (i dont know if this a correct way to do this)
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:imacstestConnectionString %>"
SelectCommand="SELECT FROM [t_CustomerAcct]"
thanks,
View 1 Replies
View Related
Aug 13, 2007
hi all,i am using sqldatasource for gridviewso that i can edit and update any row at the same place ..... and not to write any code for that....now later on if i wanna change the selectcommand of that sqldatasource how can i ? so that the edit and update will be same as it was....
View 2 Replies
View Related
Aug 21, 2007
Hi,
I'm trying to go through a checkbox list and inserting them into a database using a sqldatasource with the following code:For Each li As ListItem In Locations_Checkbox.Items
If li.Selected = True Then
Dim DataSource2 As SqlDataSource = CType(InsertProgrammeLocations, SqlDataSource) DataSource2.InsertParameters.Add("ProgrammeID", li.Value)
DataSource2.Insert()
End If
Next
When more than one checkbox is ticked, I'm getting the error 'The variable name '@ProgrammeID' has already been declared'. How do I close or reset my Datasource before I try and use it again?
Thanks for your help
View 3 Replies
View Related
Oct 28, 2007
please explain selectparameter collection and conflict detection property and filterparameter
mohsen
View 1 Replies
View Related
Oct 29, 2007
Hi, I want to know when to use an sqlDataSource object because I used to populate for example a listBox control in visual studio net 2003 from AQLK server database by using a connection object, command object, dataAdapter object and a DataSet object. I discovered if I use sqlDataSource object (using visual studio net 2005) ,all I need is to write the connection string and a Select statement as properties for that sqlDataSource, so why to use the above mentioned objects(connection,command,adapter,dataset) while I can access any database in sql server through the use of sqlDataSource?
I appreciate if you can explain to me the difference and when to use an sqlDataSource
thx
View 1 Replies
View Related
Dec 4, 2007
How can I update more than one table with one UpdateString in SqlDataSource?
View 5 Replies
View Related
Dec 9, 2007
Hi,
I have an application w/ n-tier design so I've never used the SqlDataSource up to this point but having to do my own sorting for GridViews is not something I want to keep dealing with. I'd like to take advantage of some of the packaged features too.
My question is: are there any purists out there who opted to use SqlDataSource. If so, what do you think about it? It's nice that SqlDataSource makes things simple but having data classes and dealing w/ exceptions in those classes certainly make an application pretty robust. Should I entertain the idea of using SqlDataSource or stay as a purist and keep doing things the old fashioned way?
View 1 Replies
View Related
Dec 30, 2007
How to display returned data from sqldatasurce in a textbox.
This code is not working TextBox1.Text = SqlDataSource2.ToString(); Thanks Lot.
View 2 Replies
View Related
Jan 16, 2008
Hey all,I've just started to use asp.net and so far have found it fairly easy. The only problem I've come across is with putting variable clauses into the SqlDataSources.This is one example of what I've done trying to get this to work. <asp:SqlDataSource ID="ClaimsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT TOP 20 dbo_ClaimStatus.ClaimStatus, dbo_CLAIMS.PACKET, dbo_INSURED.NAME, dbo_FEES.INSURER, dbo_FEES.CLAIM_NUMBER, dbo_CLAIMS.LOSS_DATE, dbo_CLAIMS.RECEIVED, dbo_CLAIMS.LOSS_LOCATION, dbo_CLAIM_TYPES.CODE FROM ( ( ( ( dbo_CLAIMS INNER JOIN dbo_CLAIM_TYPES ON dbo_CLAIMS.CLAIM_TYPE = dbo_CLAIM_TYPES.CODE ) INNER JOIN dbo_ClaimStatus ON dbo_CLAIMS.StatusID = dbo_ClaimStatus.ClaimStatusID ) INNER JOIN dbo_FEES ON dbo_CLAIMS.PACKET = dbo_FEES.PACKET ) INNER JOIN dbo_INSURED ON dbo_CLAIMS.PACKET = dbo_INSURED.PACKET ) WHERE dbo_ClaimStatus.ClaimStatus = @claimStatus"> <FilterParameters> <asp:QueryStringParameter Name="claimStatus" QueryStringField="ctl00$MainContent$claimStatus" /> </FilterParameters></asp:SqlDataSource>I'm posting claimStatus from a previous page using PostBackUrl on an <asp:Button /> tag and claimStatus is an <asp:DropDownList /> tag.Any idea's as to why this doesn't work?Nalum
View 2 Replies
View Related
Feb 24, 2008
Dear Friends in my project , i' ve used two SqlDataSource, one button and one gridview control;
the process that i want to do is when i click the button control ,according the if structure in this button control ; one of the SqlDataSource control assign to the gridview control DataSource property (but i assign the DataSourceID property for the gridview , it runs);
but i couldnt do it, what can i do for it? (my code doesnt give any errors but doesnt do anything too)
my code is here;
protected void btnSearch_Click(object sender, EventArgs e) { if (txtSearch.Text != null){ SqlDataSource3.SelectParameter["key"].DefaultValue = txtsearch.Text; Gridview1.DataSource = SqlDataSource3; GridView1.DataBind(); } else { SqlDataSource1.SelectParameters["keySession"].DefaultValue = cbSession.SelectedItem.ToString(); SqlDataSource1.SelectParameters["keyClass"].DefaultValue = cbClass.SelectedItem.ToString(); SqlDataSource1.SelectParameters["keyUnit"].DefaultValue = cbUnit.SelectedItem.ToString(); Gridview2.DataSource = SqlDataSource1; GridView2.DataBind(); }
View 1 Replies
View Related