sqldatasource

asp.net dropdownlist - add blank line before db values

半城伤御伤魂 提交于 2019-12-18 11:42:58
问题 On my page I have a DropDownList which I populate with database values from an SqlDataSource (see code below). How can I add my own text or a blank line before the values? <asp:DropDownList ID="drpClient" runat="server" Width="200px" AutoPostBack="True" DataSourceID="dsClients" DataTextField="name" DataValueField="client_id"> </asp:DropDownList> <asp:SqlDataSource ID="dsClients" runat="server" ConnectionString="my_connection_string" ProviderName="System.Data.SqlClient" SelectCommand="SELECT

“Server” vs “Data Source” in connection string

半世苍凉 提交于 2019-12-17 15:53:08
问题 I'm new to SqlServer, right now I have SqlLocalDb installed to work locally. Good, but I can see two connection strings typically and both works: Data Source=(localdb)\v11.0;Integrated Security=true; and Server=(localdb)\v11.0;Integrated Security=true; What exact difference is there between the two? 回答1: For the full list of all of the connection string keywords, including those that are entirely synonymous, please refer to the SqlConnection.ConnectionString documentation: These are all

ASP.NET C#: SqlDataSource with Stored Procedure and Parameters

醉酒当歌 提交于 2019-12-14 04:08:34
问题 I am trying to have a SqlDataSource coded programmatically with stored procedure and with parameters. Later I want to assign this SqlDataSource to a listbox as a datasource.But I am getting an error that the stored procedure needs a parameter that wasn't supplied. I do not understand why its giving me the error despite supplying it. The Code I am using is as below: sqlDS = new SqlDataSource(); sqlDS.ConnectionString = DC.ConnectionString; sqlDS.SelectCommandType = SqlDataSourceCommandType

Passing Windows User Id as parameter to SQLDataSource gives databinding exception

女生的网名这么多〃 提交于 2019-12-13 21:32:59
问题 First question is, Am I on the right path?.ıs there a better way to pass it as parameter? If I am on the right path, please show me how can I solve the below error. The following solution does not help me with this problem: HTTPContext.Current.User.Identity.Name not working inside a control? My code: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyDbConn %>" SelectCommand="SELECT id, Bookname, RequestType, Requestor, RequestDate FROM Requests

asp.net encrypted membership password & username retrieval

ε祈祈猫儿з 提交于 2019-12-13 21:30:36
问题 I can't seem to find out how I should decrypt the encrypted password using sha1 via the membership provider. I can't use the .GetPassword() method here because I'm retrieving the values from a sqldatasource and placing them into a gridview. Here's the gridview: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="UserId" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display." OnSelectedIndexChanged="GridView1_SelectedIndexChanged" >

Connecting two MySQL data source using a single Connection object

时光总嘲笑我的痴心妄想 提交于 2019-12-13 21:18:58
问题 Actually I need to connect two mysql datasource which are created in my application server. I'm using JPA2.0 I tried the following code. but i'm getting exception " java.lang.IllegalStateException: Local transaction already has 1 non-XA Resource: cannot add more resources. ". import com.google.common.collect.Lists; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import java.util.List; import javax.annotation.Resource; import javax.sql.DataSource; public

Gridview is not displayed when using stored procedure in SQLDatasource

核能气质少年 提交于 2019-12-13 14:14:09
问题 I stumbled across this before and I know it is a common problem. One related question is GridView is empty. But it does not solve my problem. Ideally what I want is update my gridview depending on the value in a textbox when I click the 'Find' button. It does work for me in my other page. But I have some problem here. I have not changed any default parameters. Here is the gridview <asp:GridView ID="GridView1" runat="server" AllowPaging="True" DataSourceID="SqlDataSource1" AutoGenerateColumns=

How to add Item to SqlDataSource databound list

我怕爱的太早我们不能终老 提交于 2019-12-13 12:38:56
问题 I am lazy - and I am using a SQLDataSource to populate my dropdownLists. The Databind event for the databound objects is called before the Page.PreRender so I am doing something like this in the PreRender eventHandler: private void InitializeDropDown() { this.myDropDown.Items.Insert(0, new ListItem("-- Select something --")); } I know I can set AppendDataBound items to true and hardcode my custom item in the markup but before reverting to that I'd like to understand why what I am doing is not

SqlDataSource Timeout. OK in Management Studio

人盡茶涼 提交于 2019-12-13 04:15:53
问题 In code that I inherited, I have a SqlDataSource that has a fairly complex select statement that for certain SelectParameters, always times out ("Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."). When I run the exact same query with the same parameters in management studio, the query never times out and always takes less than a second. Does anyone have an idea what the problem could be here? I can't make sense of it. 回答1: Just

Can I use connection pooling with SQLDatasource?

霸气de小男生 提交于 2019-12-13 03:47:49
问题 After reading documentation about Connection Pooling, I learned that ADO.NET uses Connection pooling by default. But the application that I am working with using SQLDatasource and I wonder if I can use Connection Pooling? If yes, is there a quick tutorial around? 回答1: My guess would be that it uses System.Data.SqlClient in turn so that as long as you use the same connection string, pooling will work. I think you can test it quite easily though. Just spawn up a bunch of these from code and