Questions tagged [sqldatasource]
The SqlDataSource control enables you to use a Web control to access data located in a relational database, including Microsoft SQL Server and Oracle databases. The SqlDataSource control uses ADO.NET classes to interact with any database supported by ADO.NET. You can use the SqlDataSource control with other controls that display data, such as the GridView, FormView and DetailsView controls to display and manipulate data using little or no code.
sqldatasource
972
questions
158
votes
4
answers
69k
views
"Server" vs "Data Source" in connection string
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;
...
31
votes
5
answers
68k
views
asp.net dropdownlist - add blank line before db values
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="...
31
votes
10
answers
118k
views
How to pass a variable to the SelectCommand of a SqlDataSource?
I want to pass variable from the code behind to the SelectCommand of a SqlDataSource?
I don't want to use built-in parameter types (like ControlParameter, QueryStringParameter, etc)
I need to pass a ...
17
votes
2
answers
43k
views
GridView with merged cells
I need to display data in grid view with merged rows for some columns. Please help me to prepare a grid view in below defined format:
And the original data comes from database is in below format:
...
16
votes
4
answers
11k
views
SqlDataSource vs ObjectDataSource
If a web page needs some data, why not just have a SQLDataSource call a stored procedure? Why use an ObjectDataSource to call a business object that then calls the stored procedure? I understand that ...
12
votes
5
answers
147k
views
How to clear exisiting dropdownlist items when its content changes?
ddl2 populates based on ddl1 selected value successfully.
My issue is the data that is already present in ddl2 does not clear before appending the new data so ddl2 content just continues to grow ...
12
votes
1
answer
10k
views
Unexpected token UNIQUE, requires COLLATION in statement [SET DATABASE UNIQUE])
Whenever I connect to HSQLDB from my application deployed on JBoss 5.1, it throws exception as : Caused by: org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (...
12
votes
4
answers
8k
views
Clear cache in SqlDataSource
I need to manually clear the cache on a SqlDataSource with caching enabled. I've tried setting EnableChaching = false, and CacheDuration = 0 (as well as = 1) and none seem to expire the content ...
10
votes
3
answers
16k
views
How to use User.Identity.Name as a parameter for SqlDataSource in ASP.NET?
For SqlDataSource I can configure the external source for the incoming paramater.
For example it might be a QueryString, Session, Profile and so on.
However I do not have an option to use User as a ...
10
votes
6
answers
69k
views
How to set SelectedValue of DropDownList in GridView EditTemplate
I am trying to do this as asked earlier. The only difference that I found is additional List item that was included in above code.
I tried to use AppendDataBoundItems=true but it is still not working....
9
votes
2
answers
8k
views
asp:QueryStringParameter and empty query string parameter
I haveasp:GridView displaying client requests using asp:SqlDataSource. I want to limit displayed information by client:
View.aspx has to display everything, View.aspx?client=1 has to display only ...
9
votes
2
answers
3k
views
How to set up ASP.NET SQL Datasource to accept TVP
In the codebehind you would add the TVP as a SqlDbType.Structured for a stored procedure
But this doesn't exist in an ASP.NET SqlDataSource control.
I have stored my Datatables in session variables (...
8
votes
8
answers
52k
views
How can I set the sqldatasource parameter's value?
I'm trying to set the value of the sqldatasource's selectcommand parameter @ClientID as in the code below, but it's not working out.
My code:
Dim strCommand = "SELECT caller_id, phone, name, ...
8
votes
7
answers
13k
views
how to count the fetched rows by sqldatasource
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim LoginChecker As New SqlDataSource()
LoginChecker.ConnectionString = ConfigurationManager....
7
votes
4
answers
4k
views
What's the purpose of Datasets?
I want to understand the purpose of datasets when we can directly communicate with the database using simple SQL statements.
Also, which way is better? Updating the data in dataset and then ...
6
votes
2
answers
4k
views
empty gridview although the sqldatasource has values
I have really weird situation.
I've created new aspx page, and without using ANY custom logic objects (everything created with visual studios wizards) tried to create grid view from sqldatasource.
...
6
votes
7
answers
5k
views
Can I get the query that was executed from the SqlDataSource?
I have a sql query for my SelectCommand on my SqlDataSource. It looks like the following:
SELECT * FROM Books WHERE BookID = @BookID
A TextBox feeds the @BookID parameter using an Asp:...
6
votes
1
answer
2k
views
Sql Equivalent to UInt16
I know that the Sql equivalent of Int16 is SqlInt16.
But what is the Sql equivalent of UInt16, UInt32 and Uint64?
6
votes
1
answer
112
views
Access The Data Retrieved
I have been trying to find an answer to this question now for days and I find it hard to believe that this can't be done.
I want to get to the DataSet/DataTable that is built when a SqlDataSource....
5
votes
2
answers
12k
views
how do I check that a SqlDataSource returned data?
I have an asp.net page that has several SqlDataSources defined that feed data into some graphs. The graph product does not handle "no data" gracefully, and throws an exception. I'd like this to handle ...
5
votes
2
answers
7k
views
Must declare the scalar variable "@LoggedInUser". Error when trying to add parameter to SqlDataSource
I am using SqlDataSource to show records based on the logged in user ,
<asp:SqlDataSource ID="ModifyCustomerDataSource" SelectCommand="SELECT cApplicationNo,cFirstName,cMiddleName,cLastName,nTelNo,...
5
votes
3
answers
22k
views
How to specify parameter value for stored procedure in SqlDataSource
Being new to using the declarative syntax of SqlDataSource I am trying to figure out a way to set the value of a parameter to a stored procedure. I have a Client_ID that is passed via the Request ...
5
votes
1
answer
6k
views
Adding ControlParameter to SqlDataSource prevents query and databinding?
I have a SqlDataSource that calls a stored procedure and it works fine. If I add a <ControlParameter> tag to add an additional argument, then the query never fires and the databinding never ...
5
votes
4
answers
37k
views
How to sort columns in an ASP.NET GridView if using a custom DataSource?
I can't get my GridView to enable a user to sort a column of data when I'm using a custom SqlDataSource.
I have a GridView in which the code in the ASP reference to it in the HTML is minimal:
<...
5
votes
1
answer
4k
views
ORA-01036: illegal variable name/number C# (SqlDataSource) Oracle 11g
I am facing problem in updating the form view values using sqldatasource bind with Oracle database.
My Select and Insert events are working properly, all columns and parameters are correct.
But ...
5
votes
2
answers
2k
views
Gridview why all visible rows are set to dirty?
I'm using the BulkEditGridView control as discussed http://roohit.com/site/showArc.php?shid=bbb62, and it's perfect for my needs. The problem I'm having is that whenever I save, every visible row (I ...
5
votes
4
answers
28k
views
'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value
I'm using TemplateField in GridView to implement edit/delete from database.
I'm Querying Data with the SqlDataSource Control.
when I edit the Table from page I get following error:
'...
5
votes
1
answer
779
views
Error passing Session Variable to SQLDataSource
I'm trying to run Project.aspx. Admin.apsx, when the 'VIEW PROFILE' button is clicked, is supposed to create a session "project_id" so the two SQLDataSources get the project_id values from the Session(...
4
votes
1
answer
55k
views
ASP.Net: drop down list and data source created dynamically
I have about 10 drop down list controls that get populated. Instead of copying/pasting and modifying a few fields on each, I would like to create them programmatically. Can this be done?
Here is ...
4
votes
5
answers
13k
views
How to handle exceptions with a SqlDataSource
I have a SqlDataSource that is supplying data to my GridView. Thats all i am using on my form, thus i have NO code behind at all. But somewhere i need a TRY CATCH block just in case my connection get'...
4
votes
4
answers
11k
views
Dynamic WHERE clauses in a SqlDataSource
I'm using a SqlDataSource in a very simple application. I'm allowing the user to set several search parameters for the SDS's select command via TextBoxes, one TextBox per parameter (think ...
4
votes
2
answers
32k
views
Changing SqlDataSource.SelectCommand at runtime breaks pagination
I have a GridView bound to a SqlDataSource with a default SelectCommand defined as such:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataSet"
ConnectionString="<%...
4
votes
2
answers
5k
views
Skip setting value of sql parameter in SqlDataSource in WebForm
I am making a WebForm in asp.net and I want to display gridview with data from asp:SqlDataSource
My problem becomes when I try to skip (pass null) values for some of the Parameters.
Here is some ...
4
votes
2
answers
18k
views
SQLDatasource parameters
How can i set sql parameters for an sqlDatasource in the code behind?
I am trying like this:
int id=1;
SqlDataSource1.SelectCommand = "SELECT * FROM categ WHERE id=@id";
SqlDataSourceArticole....
4
votes
2
answers
15k
views
ASP.NET Setting parameter for SqlDataSource programatically does not work for postback
I want to set a parameter for a SqlDataSource programmatically as described in Step 5 at http://www.asp.net/data-access/tutorials/using-parameterized-queries-with-the-sqldatasource-vb . Also a ...
4
votes
4
answers
12k
views
How to pass property value in SqlDataSource selectCommand where conditon?
I have a property in my page2.aspx.cs page
public int? Id
{
get
{
if (ViewState[Page1.Id] != null)
return Convert.ToInt32(ViewState[Page1.Id]);
...
4
votes
2
answers
6k
views
Gridview is not displayed when using stored procedure in SQLDatasource
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 ...
4
votes
2
answers
7k
views
SqlDataSource Insert code behind variable
I have the following SqlDataSource
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:orangefreshConnectionString1 %>"
...
4
votes
2
answers
2k
views
How to sanitize a query string when used with a databound repeater control?
Given the following URL:
domain.com/page.aspx?id=123
How can I sanitize that query string value when it is used on a Databound Control such as a repeaters SqlDataSource?
<asp:SqlDataSource ID="...
4
votes
2
answers
5k
views
Why won't my UpdatePanel update my Listbox as I expect on button click?
I have a form with a dropdownlist, two buttons, and two Listboxes inside an UpdatePanel. The Dropdownlist, and listboxes are all bound to SqlDatasources. The dropdownlist allows you to choose your ...
4
votes
1
answer
2k
views
SqlDataSource_OnSelected: Get data (DataTable) without re-executing the query
I have a SqlDataSource bound to a GridView with an SQL that takes about 10 seconds to retreive the data.
Also there is a UserControl called "PageSizeControl" which hooks the selected-event of the ...
4
votes
3
answers
779
views
Use of SqlDataSource From Non-Control Situations
As part of my common utilities I used in all my line of business applications, I have this code...
using System.Web.UI.WebControls;
public class Database
{
/// <summary>
/// ...
4
votes
1
answer
889
views
Why does my DbProviderFactory perform differently than SqlClientFactory?
I implemented a custom DbProviderFactory which returned the SqlX types except I added the following logic to CreateCommand
public override DbCommand CreateCommand()
{
var cmd = new SqlCommand();
...
4
votes
2
answers
2k
views
Using a dropdownlist control inside a formview
I am new to asp.net and i have a problem using a dropdownlist control inside a formview and passing its value to the related sqldatasource. When i use the code below i get the following exception
...
3
votes
1
answer
13k
views
Converting a DBNull to boolean when binding to checkbox in a detailsview control
This is kind of silly but I have a DetailsView that binds to a record in my database using a sqlDataSource. My problem is that the field I'm binding to is a bit field, (i,e 1 or 0) that at present ...
3
votes
3
answers
14k
views
How to get the datasource of a gridview
I am using a gridview with sqldatasource. How to get back the datasource in the codebehind as a datatable?
3
votes
2
answers
7k
views
Total Row Count SqlDataSource GridView
So I have a GridView set up to a SqlDataSource. Paging is enabled and I have a drop down menu that changes the number of rows displayed per page. I am able get the total of rows displayed in a single ...
3
votes
1
answer
3k
views
How can I debug the parameters passed when using an inline sqldatasource?
Say I have some sort of datagrid or repeater on a .aspx page, and my data source is defined inline like:
<asp:SqlDataSource ID="ds1" runat="server" ConnectionString="..."
SelectCommand="some_proc" ...
3
votes
2
answers
5k
views
Does a Sql Datasource run a select query on load if no contol binds is bound to it?
How can I configure a gridview and datasource on a page to only execute the query if the user clicks a button?
The datasource will return over 1 million records and the page will be accessed by a lot ...
3
votes
1
answer
11k
views
Sort gridView by proper column which is TemplateField
I have got problem with sorting column in gridView. I want to select only those rows in column which name equal for example "Finished"
My gridView consists of few BoundField and TamplateFields. When ...