Skip to main content

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
Filter by
Sorted by
Tagged with
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; ...
nawfal's user avatar
  • 72.3k
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="...
thegunner's user avatar
  • 7,053
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 ...
ahmed's user avatar
  • 14.6k
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: ...
himanshu's user avatar
  • 434
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 ...
Dumb Questioner's user avatar
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 ...
DreamTeK's user avatar
  • 33.6k
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: (...
Satya's user avatar
  • 2,094
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 ...
azollman's user avatar
  • 211
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 ...
Wodzu's user avatar
  • 6,959
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....
Shantanu Gupta's user avatar
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 ...
abatishchev's user avatar
  • 99.6k
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 (...
Matthew's user avatar
  • 10.4k
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, ...
thegunner's user avatar
  • 7,053
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....
user481831's user avatar
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 ...
Lizzy's user avatar
  • 2,123
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. ...
SimSimY's user avatar
  • 3,656
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:...
Xaisoft's user avatar
  • 46.3k
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?
user366312's user avatar
  • 16.4k
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....
dscarr's user avatar
  • 1,830
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 ...
julio's user avatar
  • 6,688
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,...
Priyank Patel's user avatar
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 ...
webworm's user avatar
  • 10.9k
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 ...
Seth Petry-Johnson's user avatar
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: <...
Ben L's user avatar
  • 6,918
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 ...
himanshu's user avatar
  • 434
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 ...
MAW74656's user avatar
  • 3,497
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: '...
GorvGoyl's user avatar
  • 47.2k
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(...
Brian's user avatar
  • 2,031
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 ...
dotnet-practitioner's user avatar
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'...
Etienne's user avatar
  • 7,141
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 ...
Windy's user avatar
  • 79
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="<%...
Mark Richman's user avatar
  • 29.5k
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 ...
adopilot's user avatar
  • 4,450
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....
hhh3112's user avatar
  • 2,187
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 ...
harrije's user avatar
  • 407
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]); ...
Rocky's user avatar
  • 4,494
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 ...
TheTechGuy's user avatar
  • 17.1k
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 %>" ...
Jorg Ancrath's user avatar
  • 1,447
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="...
Michael Jasper's user avatar
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 ...
Lucretius's user avatar
  • 1,053
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 ...
Vortex852456's user avatar
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> /// ...
mason's user avatar
  • 32.5k
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(); ...
Arrya Regan's user avatar
  • 1,114
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 ...
rematnarab's user avatar
  • 1,295
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 ...
gsirianni's user avatar
  • 1,354
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?
Geeth's user avatar
  • 5,332
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 ...
cocoa's user avatar
  • 3,851
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" ...
loyalflow's user avatar
  • 14.7k
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 ...
jgok222's user avatar
  • 314
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 ...
Jaro's user avatar
  • 43

1
2 3 4 5
20