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.

967 questions
150
votes
4 answers

"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; and Server=(localdb)\v11.0;Integrated…
nawfal
  • 70,104
  • 56
  • 326
  • 368
31
votes
5 answers

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?
thegunner
  • 6,883
  • 30
  • 94
  • 143
30
votes
10 answers

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 variable, but the following example does not…
ahmed
  • 14,316
  • 30
  • 94
  • 127
17
votes
2 answers

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: Please help me to find best way for doing this task…
himanshu
  • 442
  • 2
  • 7
  • 17
16
votes
4 answers

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 other apps (lets say desktop apps) built on the…
Dumb Questioner
  • 2,147
  • 4
  • 20
  • 21
12
votes
4 answers

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 already in the cache - although they do seem to prevent…
azollman
  • 211
  • 6
  • 15
12
votes
1 answer

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: (java.sql.SQLException: error in script file…
Satya
  • 2,094
  • 6
  • 37
  • 60
12
votes
5 answers

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 every time ddl1 is changed.
DreamTeK
  • 32,537
  • 27
  • 112
  • 171
10
votes
3 answers

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 source. I know that I could provide value for the…
Wodzu
  • 6,932
  • 10
  • 65
  • 105
10
votes
5 answers

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. I also want to set the its default value to the…
Shantanu Gupta
  • 20,688
  • 54
  • 182
  • 286
9
votes
2 answers

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 (don't worry they are small!) and I need to pass…
Matthew
  • 10,244
  • 5
  • 49
  • 104
9
votes
2 answers

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 requests from client ID #1. So I'm using…
abatishchev
  • 98,240
  • 88
  • 296
  • 433
8
votes
8 answers

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, email FROM callers WHERE…
thegunner
  • 6,883
  • 30
  • 94
  • 143
8
votes
7 answers

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.ConnectionStrings("A1ConnectionString1").ToString() …
user481831
  • 953
  • 2
  • 7
  • 8
7
votes
4 answers

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 transfering them to the database at once or updating the…
Lizzy
  • 2,033
  • 3
  • 20
  • 33
1
2 3
64 65