Multiple SqlDataSource Controls On A Page
Jun 8, 2007
Thanks for your help.
I'm just getting into ASP.NET 2.0 and started using the SqlDataSource control to declaritively connect to a database. I was wondering if I have two SqlDataSource controls on one page with two select commands querying the same database, will the that create to seperate instances of opening and closing the connection to the database, or will it open the database once, execute both queries, and then close the connection. It seems that if it creates two separate connections, it would still be more efficient to to connect to the database programmatically using ADO.NET. You would only need to make one trip to the database, pull down all of your data, and then close the connection.
Adrian
View 1 Replies
ADVERTISEMENT
Mar 4, 2007
NET 2.0
I am using Visual Studio Express 2005 for database web developement.
I have created a database with 5 tables. Two are associative tables.
They are
SoftwarePK SoftwareID Title
SoftwareSolutionFK SoftwareIDFK SolutionID
SolutionPK SolutionID Title
CategorySolutionFK CategoryFK Solution
Category
PK Category Title
Criteria for a search with three sources of input into a SqlDataSource attached to a FormView for paged out.
The following are the Search Criteria input sources:1) ListBox in Multiple Selection Mode2) CheckBoxList with Mutiple checks posible2) TextBox with key word search in Title.
Each Solution has 0 or many Categories and 0 or many Software.
When the records are entered in the database, the associative information for Categories and Software are populated to filter thereturned values.
In NET 1.1, I would create a search string like the following in code behind by looping through the CheckBoxList and ListBox finally adding the TextBox:
SELECT Solution.SolutionID, Solution.Title FROM SolutionWHERE Solution.SolutionID IN ('2','3','5') AND Solution.Title LIKE '%Math%'
I am unable to update the SelectCommand in the ASPX page.
However, when I use the I have used theSystem.Web.UI.WebControls.SqlDataSources"SelectQuery Builder"I receive the following in the Source for ASPX: <asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT Solution.SolutionID, Solution.Title
FROM
Solution INNER JOIN CategorySolution ON Solution.SolutionID = CategorySolution.SolutionID
INNER JOIN SoftwareSolution ON Solution.SolutionID = SoftwareSolution.SolutionID">
<SelectParameters>
<asp:ControlParameter ControlID="CheckBoxList1" DefaultValue="%" Name="CategoryID" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="ListBox1" DefaultValue="%" Name="SoftwareID" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="txtTitleSearch" DefaultValue="%" Name="Title" PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource> I receive duplicate records and not sure if the code generated accesses the Mutiple Selected values in the CheckBoxList1 and ListBox1.Question: 1) If the SelectQuery generator will not access multiple selected values from the CheckBoxList1, how can I use code behind to replaceSelectCommand in the ASPX page?2) What is the best solution for using the CheckBoxList1, ListBox1, and TextBox for filtering my results? Sample code, references to solutions, corrections on logic, a new approach, how to use the wizard correctly would all be greatly appreciated.3) Can Multiple Selection Controls be use with a SqlDataSource SELECT Command?Thanks for your time,Sincerely,Unhistoric
View 2 Replies
View Related
May 9, 2007
Hi, I am porting a massive VB6 project to ASP.net 2005. Most of the code is fine, however because the original developers used lots of data controls and my own time restrictions I thought to replicate the functionality by using Sqldatasource controls instead.
These data controls are bound to DBtruegrids. The project has has lots of code like...
AdodcOrders.Recordset.RecordCount > 0 or If AdodcOrders.Recordset.EOF or AdodcOrders.Recordset.MoveNext() or
AdodcDetail.Recordset!FieldName
The problem is the sqldatasource control doesn't have a recordset/dataset property which I can access and manipulate, or does it? What should I do to get round these? The project has thousands of lines like this in so its not feasible to rewrite it (although if I could I would!).
Any suggestions please gratefully appreciated.
many thanks
mike
View 1 Replies
View Related
Nov 26, 2006
Hi,
I placed several SqlDataSource objects on my page which work with the same database (same connection string).
As I know, connection operation to database is costly in the performance prespective.
Do these SqlDataSource controls work with the same connection object or each of them create his own connecton object?
If each create it's own, then can they be changed to work with one connection object?
Thanks
View 3 Replies
View Related
Nov 19, 2007
I created a user control file with 3 properties. I would like to call this user control in a datalist control in the hosting page and pass the properties from a sqldatasource control. To this end I have a code like below;
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"SelectCommand="SELECT [1], [2], [3] FROM [table1]"></asp:SqlDataSource>
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" DataMember="DefaultView" >
<ItemTemplate>
<uc:kk ID="kk1" runat="server" One='<%# Eval("1") %>' Two='<%# Eval("2") %>' Three='<%# Eval("3") %>' /></ItemTemplate></asp:DataList> I don't get any errors when I run the page, however it won't work as I wish. Only thing that appears in the rows of datalist is "01.01.0001 00:00:00".
View 4 Replies
View Related
May 9, 2008
hello friends iam newlly joined in to company any one can help me how to bind individual controls to a single SqlDataSource Control..
my problem is "i have different text boxes and dropdown boxes and what i want to do is if i enter primary ker field(employeeno) in the text box automatically i need to get that particular record and i need to populate it to the Respective controls...
is there any chance of doing this by using a single datasource control..
pls help me its urgent
Regards
k.seshu
View 3 Replies
View Related
Jun 30, 2007
All,
My ISP does not allow me to remotely connect to my hosted SQL Server DB--how can I use SQLDataSource and other data bound controls in development?
Here are my specs:
IDE: Visual Web Developer Express 2005
Database: MS SQL Server
ASP Version: ASP.NET 2.0
The SQL Server is hosted centrally at the ISP; basically I have been given the connection string parameters.
My question is this:
Do I use two web.config files (one for when I develop locally and one for when I deploy remotely)? If so, how? Will the SQLDataSource control find the connection string defined in web.config on the remote server? I don't want to have to write all of the database code and it would be a big loss of one of the major benefits of using ASP.NET 2.0 if I do.
Any help will be greatly appreciated,
Leslie
View 4 Replies
View Related
Nov 21, 2006
Hi all,
I have a gridview bound with a SQLDataSource. I am using the Update feature of the SQLDataSource to update a SQL Server database with values entered into the gridview. However I am not getting it to work. I believe this is due to the controls that contain the user entries are not the gridview itself, but rather child controls within the gridview. I have been using the names of the actual controls but nothing happens. Upon submit, the screen returns blank, and the database is not updated. Here is some code:
<asp:GridView ID="GridEditSettlement" runat="server" AutoGenerateColumns="False" BackColor="Navy"
BorderColor="IndianRed" BorderStyle="Solid" Font-Names="Verdana" Font-Size="X-Small" DataSourceID="SqlDataSource_grid" AllowPaging="True" AllowSorting="True" ForeColor="White" DataKeyNames="legid">
<Columns>
<asp:CommandField ShowEditButton="True" CancelImageUrl="~/App_Graphics/quit.gif" CancelText="" EditImageUrl="~/App_Graphics/EditGrid.GIF" EditText="" UpdateImageUrl="~/App_Graphics/save.gif" UpdateText="" ButtonType="Image" />
<asp:BoundField DataField="StartDate" HeaderText="Start Date" ReadOnly="True" />
<asp:BoundField DataField="EndDate" HeaderText="End Date" ReadOnly="True" />
<asp:BoundField DataField="CounterpartDealRef" HeaderText="CP Deal Ref" ReadOnly="True" />
<asp:TemplateField HeaderText="Preliminary Settlement Price" ><ItemTemplate>
<asp:Label ID=lblPreliminary runat=server Text='<%# Bind("PrimarySettlementPrice") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID=txtPrimaryPrice Text='<%# Bind("PrimarySettlementPrice") %>'></asp:TextBox>
</EditItemTemplate></asp:TemplateField>
<asp:TemplateField HeaderText="Agreed Settlement Price"><ItemTemplate>
<asp:Label ID=lblAgreed runat=server Text='<%# Bind("AgreedSettlementPrice") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID=txtAgreedPrice Text='<%# Bind("AgreedSettlementPrice") %>'></asp:TextBox>
</EditItemTemplate></asp:TemplateField>
<asp:BoundField DataField="Volume" HeaderText="Volume" ReadOnly="True" />
<asp:BoundField DataField="Price" HeaderText="Price" ReadOnly="True" />
<asp:BoundField DataField="TotalVolume" HeaderText="Total Volume" ReadOnly="True" />
<asp:BoundField DataField="InstrumentName" HeaderText="Instrument" ReadOnly="True" />
<asp:BoundField DataField="NominalValue" HeaderText="Nominal Value" ReadOnly="True" />
<asp:BoundField DataField="Strike" HeaderText="Strike" ReadOnly="True" />
<asp:BoundField DataField="DeliveryDate" HeaderText="Delivery Date" ReadOnly="True" />
<asp:TemplateField HeaderText="LegId" SortExpression="LegId">
<ItemTemplate>
<asp:Label ID="lblLegID" runat="server" Text='<%# Bind("LegId") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID=txtLegID Text='<%# Bind("LegId") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#FFFF66" ForeColor="#333333" />
<EditRowStyle BackColor="#FFFF66" Font-Names="Verdana" Font-Size="X-Small" ForeColor="#333333" />
<PagerStyle ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#333333" />
</asp:GridView>
<br />
<asp:SqlDataSource ID="SqlDataSource_grid" runat="server" ConnectionString="<%$ ConnectionStrings:DealCaptureDev %>" SelectCommand="sp_get_single_deal" SelectCommandType="StoredProcedure" UpdateCommand="Update trDealLeg Set PrimarySettlementPrice=@primarysettlement, AgreedSettlementprice=@agreedsettlement, LastUpdate=GetDate(), LastUpdateBy=Session('userid') Where LegID=@legid" EnableCaching="True" ConflictDetection="CompareAllValues" ProviderName="System.Data.SqlClient">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="" Name="dealnum" QueryStringField="deal"
Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:ControlParameter ControlID="txtLegId" PropertyName="Text" Name="legId" />
<asp:ControlParameter ControlID="txtPrimarySettlement" Name="primarysettlement" PropertyName="Text" />
<asp:ControlParameter ControlID="txtAgreedSettlement" Name="agreedsettlement" PropertyName="Text"/>
<asp:SessionParameter DefaultValue="" Name="userid" SessionField="userid" />
</UpdateParameters>
</asp:SqlDataSource>
As seen above, controls such as txtPrimarySettlement are referenced but the update is not successful. The text boxes are within the GridEditSettlement gridview. In the .aspx code I cannot use FindControl (at least I don't think it will work).
So the questions are: Is it possible to reference the child controls, if so - how? Is there another way to do this, such as in the vb code behind - in the either the gridview's RowUpdating event or the SQLDataSource's Updating event.
What is the best approach? Anyone come up against this issue before?
Thanks,
KB
View 1 Replies
View Related
Dec 26, 2007
We are using SSRS 2005.We designed one report.This report contains Table and chart controls .When Table is hidden,chart only is visible, this chart is going to show only on last page.There is a white space in top of the chart while hiding the table control.
Consider for an Example Report one tables and one chart . We want to show only chart,So we made Table's visible property is false.Total Number of pages is five and table has only four pages and chart has only one page that is in last page. Now the report showing Four pages are empty with header and footer and last page have a chart with header and footer.
Any suggestions how to avoid the empty pages?
I tried to Filter property to filter the table.Same empty page with header and footer is only visible
Thanks In Advance
Mugesh
View 8 Replies
View Related
Nov 28, 2007
one of my webpages uses the following sql query to allow the user to search through the database and present the qualifying data in gridview:
SELECT * FROM [Table1] WHERE ([comments] LIKE '%' + ? + '%')
how could i expand this so that the user can also search through the database but instead by searching through another column such as [type]?
thanks in advance
View 11 Replies
View Related
May 10, 2006
I want to update two tables in one page. So I created two FormView bound on two SqlDataSource controls, and I create a Update button on the bottom of page. And I writen some codes as below:
btnUpate_Click(object sender, EventArgs e){
sqlDataSource1.Update();
sqlDateSource2.Update();}
But, the records haven't updated.
In SqlDataSource2_Updating() function, I found all the parameters is null.
So, how to modify my code to do it.
Zhang
View 2 Replies
View Related
Dec 10, 2007
I have a report which is multiple pages in the report viewer. Now I want to make it shown in the webpage report viewer just in one page. Is there any ways to realize it?
Thanks
View 1 Replies
View Related
Jan 21, 2008
Hi,
I have a report with 2 columns.I have a list which has 4 textboxes attached to a dataset's fields.
Report Interactive Size:8.5in, 11in
Margins:0.1in, 0.1in, 0.5in, 0.5in (L;R;T;B)
Body Size : 3.125in, 1in
List Size:2.875in, 0.75in
Each texbox is set to cangrow false
My problem is when I print that report I get only one column on the first page.
I start to get the correct report on second page which has 2 columns.
If I export to pdf, everything is is fine no problems at all.
I am using VS 2008 Pro and local reports.
What am I missing?
Thanks for help.
View 1 Replies
View Related
Nov 19, 2006
Hi,
I have the following Sql Data Source that I wish to bring back on my page:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:FrogConnectionString %>"
SelectCommand="ProposalsCheckNewCustomerData" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:FormParameter FormField="MaritalStatusID" Name="MartialStatusID" Type="Int32" />
<asp:FormParameter FormField="LivingStatusID" Name="LivingStatusID" Type="Int32" />
<asp:FormParameter FormField="DealerID" Name="DealerID" Type="Int32" />
<asp:FormParameter FormField="VehicleTypeID" Name="VehicleTypeID" Type="Int32" />
<asp:FormParameter FormField="FinanceTypeID" Name="FinanceTypeID" Type="Int32" />
<asp:FormParameter FormField="MediaSourceID" Name="MediaSourceID" Type="Int32" />
<asp:FormParameter FormField="DealerContactID" Name="DealerContactID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
The recordset brings back 7 values that I wish to populate into 7 Labels.
1. Should the SqlDataSource be on the page (between the Head tags) or within the Page_Load command of the Page Behind ?- If its on the page behind do any of you have any sample code to show me how to get the recordset up and running ?
2. How would I bind the results to a label ?- Within my old asp pages it was simple (I'm not saying its not simple here, I am still getting my head around vb.net)- eg <%=rsX("MaritalStatus")%> I guess its something very similar
Thanks for any pointersFizzystutter
View 4 Replies
View Related
Aug 29, 2006
I use SQLDataSource, bind to a GridView and a SelectParameter that gets it's value from a textbox. If the textbox is empty, then it returns all rows.How do I prevent the query and binding when the page first load? Thanks
View 11 Replies
View Related
Feb 1, 2007
i have a sqldatasource on my asp.net page -- select * from table where id = @id
i want to set the @id in the backend and set the result to textbox1.text
how do i do this?
View 1 Replies
View Related
Feb 17, 2006
1. Create a new .aspx page and add this inside the form tag: <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Comments]" InsertCommand="INSERT INTO Comments(CommentAuthor, CommentText) VALUES (@auth, @text)"> <InsertParameters> <asp:FormParameter FormField="TextBox1" Name="auth" /> <asp:FormParameter FormField="TextBox2" Name="text" /> </InsertParameters> </asp:SqlDataSource> </div>2. Add the event handler for the button in code behind: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Me.SqlDataSource1.Insert() End Sub3. Run the page, enter some text into the textboxes and hit the button. GREAT! The data was successfully inserted into the database.Now, let's try the exact same thing, but this time lets create a Master Page first. So:1. Create a new master page.2. Create a new .aspx page, check the 'select master page' checkbox and then select the newly created master page.3. Add the exact same as above in between the asp:Content begin and end tags: <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Comments]" InsertCommand="INSERT INTO Comments(CommentAuthor, CommentText) VALUES (@auth, @text)"> <InsertParameters> <asp:FormParameter FormField="TextBox1" Name="auth" /> <asp:FormParameter FormField="TextBox2" Name="text" /> </InsertParameters> </asp:SqlDataSource> </div>4. Add the event handler for the button in code behind. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Me.SqlDataSource1.Insert() End Sub5. Run the page, enter some text into the textboxes and hit the button. WHOOT!? This time it doesn't work and the following error appears:Cannot insert the value NULL into column 'CommentAuthor', table 'C:DOCUMENTS AND SETTINGSSONYMY DOCUMENTSVISUAL STUDIO 2005WEBSITESCOMMENTSAPP_DATACOMMENTS_DB.MDF.dbo.Comments'; column does not allow nulls. INSERT fails.The statement has been terminated. 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.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'CommentAuthor', table 'C:DOCUMENTS AND SETTINGSSONYMY DOCUMENTSVISUAL STUDIO 2005WEBSITESCOMMENTSAPP_DATACOMMENTS_DB.MDF.dbo.Comments'; column does not allow nulls. INSERT fails.The statement has been terminated.Source Error: Line 4: Line 5: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.ClickLine 6: Me.SqlDataSource1.Insert()Line 7: End SubLine 8: End Class Source File: C:Documents and SettingsSONYMy DocumentsVisual Studio 2005WebSitesComments2.aspx.vb Line: 6 So can anyone explain why this only works in the first example?Many thanks,
View 4 Replies
View Related
May 22, 2006
I have a page that has a drop down control that is used to control the items in a FormView. The drop down is bound to one SQLDatasource while the FormView is bound to another SQLDataSource. I've got everything working great. Selecting an item in the drop down reveals the details in the form view. the Form can be opened for editing and deleting. I even have the Insert working. But there lies my problem. Once the Insert is executed I'd like to take the Index value of the recently submitted item and set it to the SelectedIndex of my dropdown. Here is the code for each of the SQL events Sub FormViewUpdated(ByVal sender As Object, ByVal e As FormViewUpdatedEventArgs) Handles FormView1.ItemUpdated
confirmation.Visible = True
confirmation.Text = "<img src=""../img/smiley36.gif""> Your record has been updated."
Dim index As Integer = Me.DropDownList1.SelectedIndex
DropDownList1.DataBind()
Me.DropDownList1.SelectedIndex = index
End Sub
Sub FormViewDeleted(ByVal sender As Object, ByVal e As FormViewDeletedEventArgs) Handles FormView1.ItemDeleted
confirmation.Visible = True
confirmation.Text = "<img src=""../img/smiley36.gif""> Your record has been deleted."
DropDownList1.DataBind()
FormView1.ChangeMode(FormViewMode.ReadOnly)
End Sub
Sub FormViewInserted(ByVal sender As Object, ByVal e As FormViewInsertedEventArgs) Handles FormView1.ItemInserted
confirmation.Visible = True
confirmation.Text = "<img src=""../img/smiley36.gif""> Your record has been inserted."
DropDownList1.DataBind()
End Sub
I would like to do something similar to the Updated event in the Inserted sub. Notice I have a Me.DropDownList.SelectedIndex bit...I'd like to be able to set a variable to the new ID and then set the Me.DropDownList.SelectedIndex to that variable. My stored proc for the Insert reads like
ALTER PROCEDURE dbo.usp_INSERTHelp_Faq
(
@FAQQuestion varchar(500),
@FAQText ntext,
@FAQIndex varchar(500),
@ModifiedBy int,
@Help_FAQID int OUTPUT
)
AS
INSERT INTO Help_FAQ (FAQQuestion, FAQText, FAQIndex,ModifiedBy, Views)
VALUES (@FAQQuestion,@FAQText,@FAQIndex,@ModifiedBy,0)
SELECT @Help_FaqID = @@Identity
RETURN
So, the Stored Proc is set up to return the latest ID. Also, my SQLDataSource for the FormView has an InsertParameter: <asp:Parameter Direction="Output" Name="Help_FAQID" Type="Int32" />
Any thoughts on how to close the loop here? How do I get my hands on the new Help_FAQID?
View 3 Replies
View Related
Feb 22, 2008
Using 3.5
If I have a sqldatasource on the page, is it run if it is not bound to a data object like a gridview?
Seems like if i want to access the data (like set a label text) from the sqldatasource I have to use code to first create a dataview then pick throught it. This seems like I'm running it twice. I'm new at .net so I dont know how to tell.
I don't want to write data select code programatically when I can just through an SDS on the page, but wondered it it ran just because it's on the page.
View 2 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
Nov 25, 2005
Hi, I have created a search page which needs to perform different
search function in same page. I have setuped a sqldatasource then
manual
setup the connection string and command inside the codefile. So the
select command can be various depends on the event. The problem is
all of those setting will be reset after I click on the pageindex in
the girdview control to go to next pages. Since this gridview is linked
with this sqldatasource control, I need to restore the connection
string/command when user choose decide to view next page of data inisde
the
gridview.
I think I must have done something wrong in here becuase it will end up
retrieving the total amount of data when everytime user choose to
view next
or perivous page.
Can someone give me a hand on this ? Thanks
View 1 Replies
View Related
Oct 8, 2007
Hi all,
I have few insertions statements in one datasource insert command, which i use for my user creation process adding new billing info shipping info and so on.
I've put this code in createuserwizard usercreated step with a try catch code. On the insertion if it doesnt work it deletes the user account.
Well lets say the first insertion went trough with out any problems, but the second one got blocked or didnt work length or any wierd on controled issue.
I was thinking of putting begin transaction end transaction statements in front and end of the statements but this can prevent the insert not to return error, which will prevent try catch to fire?
Basicly the idea is to do all insertions with the user creation, and if one goes down all the others gets reversed. (if possible single sqldatasource, just to make the code look clean)
View 2 Replies
View Related
Sep 1, 2006
I would like to introduce myself as ASP.Net 2.0 beginner. I face a problem when using gridview and sqldatasource.
View 1 Replies
View Related
Aug 29, 2007
I have one page, one connection, and three dropdowns. The connection looks like (as an example):<asp:SqlDataSource ID="DropDownConn" runat="server" ConnectionString="<%$ ConnectionStrings:aousConnectionString %>" SelectCommand="SELECT [Value], [Text] FROM [DropDown] WHERE (([Group] = @Group) AND ([Viewable] = @Viewable))"> <SelectParameters> <asp:Parameter Name="Group" Type="String" /> <asp:Parameter DefaultValue="True" Name="Viewable" Type="Boolean" /> </SelectParameters></asp:SqlDataSource>
The DropDowns Look like this:
<asp:DropDownList ID="DropDown1" runat="server"></asp:DropDownList><asp:DropDownList ID="DropDown2" runat="server"></asp:DropDownList><asp:DropDownList ID="DropDown3" runat="server"></asp:DropDownList>The C# Code I am trying is like this:DropDownConn.SelectParameters["Group"].Equals("DropDown1");DropDownConn.SelectParameters["Viewable"].Equals(true);DropDown1.DataSourceID = "DropDownConn";DropDown1.DataTextField = "Text";DropDown1.DataValueField = "Value";DropDown1.DataBind();
As an example. I can not get it done so that I don't have to create 3 dataconnections. Any help, PLEASE?
View 2 Replies
View Related
Feb 12, 2006
Hi,Hope if someone can help me here. Keep in mind I an fairly new to .NET and SQL and am learning to break my MS Access habit :)
I have a web form that is using a SqlDataSource and a FormView control. In addition to this I have 2 text boxes. What I am trying to do is display results in the FormView based on what a user types into one of the Text Boxes (one or the other…Not both)
The SELECT statement in the SqlDataSource looks like this in concept.
SELECT Field1, Field2, Field3, Field4FROM dbo.MYTABLEWHERE (Field1 = @Field1) AND (Field2 IS NULL)OR (Field2 = @Field2) AND (Field1 IS NULL)
I have the two text boxes pointing at the parameters (@Field1 and @Field2) so in theory I would expect that when a user populates one of the text boxes and clicks a button to databind the FormView it would display a record matching that criteria…. But it’s not all I get is a blank/missing FormView.
I tried different variations on the SQL statement and tried using = '' instead of IS NULL but still the same results. However, if I populate one text box with a value that I know is not in my table and populate the other with a value of which I know exists in my table is…It works.What am I missing?
View 13 Replies
View Related
May 5, 2006
I have a gridview with a sqlDataSource with the SelectCommand as
"SELECT Movie.Title, Movie.Category, Movie.ReleaseDate, ItemForSale.Quantity, ItemForSale.HasUnLimitedQuantity FROM ItemForSale INNER JOIN Movie ON ItemForSale.ID = Movie.ID"
what kinda 'UpdateCommand' do I set so that ItemForSale is also updated from the grid? I tried two update statements seperated with a semicolon but that wouldn't work, any suggestions...
View 3 Replies
View Related
Apr 7, 2007
I was wondering, if you have multiple SqlDataSources on a single aspx page, does the framework need to open and close a SEPERATE connection for each SqlDataSource. This would make it much less efficient than coding with the ADO.NET objects and just opn and close the connection once irrespective how many quries that page needs.
Your comments would be appreciated.
View 5 Replies
View Related
Mar 7, 2008
Hi,
Could we display two tables in the same page of a report?
Many Thanks,Zulfi
View 1 Replies
View Related
Sep 11, 2006
Hello, I'm new to the forum and new to SQL, ASP.NET, etc. I am creating an intranet site for my company in VS 2005 and have run into a very annoying problem that I can't seem to solve. I have tried Googling it and came up empty. I have a database in SQL Express 2005 and my website will be accessing several tables within the database. I can retrieve info just fine and I can update, delete, etc just fine using gridview or other prebuilt tools, but when I add a few text boxes and wire a button to the SqlDataSource.Insert() command, I get a new record that is full of null values except for the identity key I have set. The kicker is that I am also using a master page and when I duplicate the web page without the master page link, everything works just fine. The following snippets show what I'm doing:<InsertParameters><asp:FormParameter Name="Name" Type="String" FormField="txtName" /><asp:FormParameter Name="Location" Type="String" FormField="ddlLocation" /><asp:FormParameter Name="Issue" Type="String" FormField="txtProblem" /></InsertParameters>Of course I match the formfields to the text boxes, create an onclick event for my button, the sqldatasource is configured correctly, it just doesn't work with the master page no matter what I do. Any help would be appreciated. Thanks
View 3 Replies
View Related
May 24, 2007
I have created a stored procedure with multiple select statements using MSSQL 2000. When I connect to this using a SQLDataSource it only seems to get the first SELECT. I need to access the multiple tables returned by the stoped procedure. Can anyone point me in the dirrection of how to do this.ThanksClearz
View 3 Replies
View Related
Oct 9, 2007
Hi,I have a stored procedure that takes 3 parameters. I am using a sqldatasource to pass the values to the stored procedure. To better illustrated what I just mention, the following is the code behind:SqlDataSource1.SelectCommand = "_Search"SqlDataSource1.SelectParameters.Add("Field1", TextBox1.Text)SqlDataSource1.SelectParameters.Add("Field2", TextBox2.Text)SqlDataSource1.SelectParameters.Add("Field3", TextBox3.Text)SqlDataSource1.SelectCommandType = SqlDataSourceCommandType.StoredProcedureGridView1.DataSourceID = "SqlDataSource1"GridView1.DataBind()MsgBox(GridView1.Rows.Count) It doesn't return any value. I am wondering is that the correct way to pass parameters to stored procedure?Stan
View 2 Replies
View Related
Dec 21, 2007
Hey all,
I am still pretty new to all of this and I am having problems accessing a the same DB twice in my page. I want to pull information once in one spot, but then pull different information in a different spot on the page. Anyway, in the first spot, I have the following code:
Dim conString As String = WebConfigurationManager.ConnectionStrings("DataConn").ConnectionString
Dim con As New SqlConnection(conString)Dim cmd As New SqlCommand("Select Team1.TeamID as Team1ID, Team1.TeamName as HomeTeam, Team2.TeamID as Team2ID, Team2.TeamName as AwayTeam, Football_Schedule.ScheduleID as ScheduleID from (Select * from Football_Teams) as Team1, (Select * from Football_Teams) as Team2, Football_Schedule where Football_schedule.team1 = Team1.teamid AND Football_Schedule.team2 = Team2.teamid order by Football_Schedule.WeekNum, Team1.TeamName, Team2.Teamname", con)Using con
con.Open()
Dim RS As SqlDataReader = cmd.ExecuteReader()
While RS.Read()
blah blah blah
End While
End Using
Then in my other spot on the page I have the following:
Dim cmdresults As New SqlCommand("Select Users.Firstname, sum(PointsID) as TotalPoints from Football_Input, Football_Schedule, Users where Football_Input.TeamID = Football_Schedule.winID and users.userid = Football_Input.UserID Group by Users.firstname")
Using con
con.Open()Dim RD As SqlDataReader = cmdresults.ExecuteReader()
While RD.Read()%>
<tr>
<td><%=RD%>
</td>
</tr>
<%End While
End Using
When I try to execute I get this error, "ExecuteReader: Connection property has not been initialized." on the following line, "
RD As SqlDataReader = cmdresults.ExecuteReader()" Any ideas? If possible a little explanation on how multiple connections to the same database work would be nice just for future reference.
Thanks in advance!!,
Chris
View 5 Replies
View Related