Click here to Skip to main content
15,903,033 members
Everything / SqlDataSource

SqlDataSource

SqlDataSource

Great Reads

by J.Jash
Data Auditing Trigger Generator
by jurhas
Spada via Modbs, Supervisory Control and Data Acquisition with visualb basic,Arduino and firebird
by SRS(The Coder)
How to use Stored Procedures in Entity Framework Model First Approach
by Jason Parms
Lightweight Directory Access Protocol (LDAP) Injection

Latest Articles

by ambilykk
How to enable SQL Express user
by John C Rayan
MyBatis.NET as DataMapper
by Member 12149082
Description of useful SVG Filters and Interactivity
by Rajesh Manjarekar
When CDC is turned ON against a table and the underlying table schema changes, such as adding/removing a column, changing datatype etc

All Articles

Sort by Title

SqlDataSource 

20 Jan 2014 by Rajib Mahata
CREATE PROCEDURE `FetchSupplierByRequest`(intConferenceId int, intRank int,intTableNo int)BEGINSELECT Distinctc.ID , c.CompanyName,c.TypeFROM conferencetabletop cp, companies c,meeting mWHERE cp.ConferenceID = intConferenceId AND c.ID = m.SupplierIDand...
22 Jan 2014 by idenizeni
According to the information I can find, older versions of MySQL cannot use variables in the LIMIT clause and constants must be used. Similar issue posted to StackOverflow with some useful information.http://stackoverflow.com/questions/2875238/passing-limit-as-parameters-to-mysql-sproc[^]
11 Oct 2013 by ASP.NET Community
The AccessDataSource class is a data source control that works with Microsoft Access databases. Like its base class, SqlDataSource, the
6 Oct 2016 by Member 8057273
Hi.I have an update panel which contains a datalist control There are some labels inside the Item Template of this datalist.Following is what I need to do:Initially datalist will show top 50 rows from the database.When I click on load more button, there will be a partial postback which...
6 Oct 2016 by Vincent Maverick Durano
First off, don't use UpdatePanel to do this. You can instead use AJAX to load the next result set on the page. You can apply the concept of "infinite scroll" to load the rest of the data while you scroll or click on the more button. Take a look at this for example:...
13 Jan 2015 by jeevakumar.T
I have this error on my software after execute time. i have use server based sql database sample.mdf. I create setup file on my project it is build successfully after I have this Error. how can I solve this Problem I beginner of .exe file creation. an attempt to attach an auto-named...
15 Oct 2015 by Member 12030955
An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user codeAdditional information: Incorrect syntax near the keyword 'Table'.here is the Registration Button Code.public partial class Registration : System.Web.UI.Page{ ...
15 Oct 2015 by _Amy
Try this:string checkuser = "select count(*) from [Table] where Username='" + tbUsername.Text + "'";//Here "Table" is a predefined word in SQL Sever. You should use it like [Table].//I hope [Table] is your table name[EDIT]Also modify in Button1_Click Event:string insertQuery =...
8 May 2010 by 4277480
Sample table to explain the problem (EmployeeID,EmployeeName,ManagerID)In my item template of my gridView I have a dropDownList which binds as follows:When you choose dataSource I set EmployeeName to be the field that is being displayed and the EmployeeID for the value. Then in the Edit...
8 May 2010 by Sandeep Mewara
4277480 wrote:After I perform an insert I am trying to apply a SqlDataSource.FilterExpression however an error is thrown saying that the value of the dropDownList is not found in the list? Did you updated the dataset after the insert? It looks like the filter is workin on the old data and...
8 May 2015 by jaylisto
i did a page where it shows data from sql database, where it is shown in a gridview. i can now then choose the id to be print or to show image in another tab.my problem is the image data type in column. at it shows no preview icon.the easy way is to set "nulldisplay" with a value "no...
9 May 2015 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
This option is available with ImageField. Property is NullImageURL.Refer - Re: how to set default image in asp.net[^]
6 May 2014 by Eric Goedhart
23 Apr 2013 by Member 9978591
Hi,Can anyone tell me why datareader is no reading user_id from this code?I debugged and the user_id_select remains 0 and I am getting no errors. Protected Sub btnAddUser_Click(sender As Object, e As EventArgs) Handles btnAddUser.Click Dim conn As New...
23 Apr 2013 by Pallavi Waikar
it is because u r already reading value from reader remove this line from code datareader.Read()i.eProtected Sub btnAddUser_Click(sender As Object, e As EventArgs) Handles btnAddUser.Click Dim conn As New SqlConnection("Data Source=BRIAN-PC\SQLEXPRESS;Initial...
23 Apr 2013 by ZurdoDev
You called .Read() twice on the DataReader. So it has advanced too far.Since you are only expecting one user record try something like this insteadIf datareader.HasRows THEN datareader.Read() user_id_select = datareader("user_id")End If
23 Apr 2013 by OriginalGriff
Brackets, my friend, brackets.Change: searchSQL.Parameters.AddWithValue("@username", txtUserSearch.Text.ToString)To: searchSQL.Parameters.AddWithValue("@username", txtUserSearch.Text.ToString())But in fact you don't need the ToString at all, since a Text property...
26 Nov 2015 by Member 12081613
I need to open/attach a Database (MDF) file in SQL Server 2012 Standard version as a Database which was created in Visual Studio 2015 and is being used in a project there. Is this possible?What I want to do is use the SQL Server Analytic project to create a cube of the data. Is this...
7 Jan 2016 by JasonClark03
One solution to this problem is described here: How can I open an .MDF file in SQL Server? (Attach Tutorial & Troubleshooting) | Learning SQL Server[^]
26 Oct 2015 by Member 11651335
Partially its work whenever i give required credential(Email and password) it works fine.if i give wrong email its show 404 error means its fine.if i give wrong password also its accepting means it not show any error.My code is given below please help me:-using System;using...
26 Oct 2015 by Richard Deeming
The first and most obvious problem is that you're ignoring the password test:string temp =Decrypt(user.Password, user.PasswordSalt);if (password == temp){ // return Ok(user.Email);}return Ok(user.Email);Whether or not the password matches, you return Ok. Try changing it...
26 Jun 2014 by Hithesh Reddy
Hi,I need to upload the excel file data into mysql server database tables. Need to automate this process using the scripts. The script should pick the file from the location and should validate the data in the excel and insert the data into the mysql table. Can anyone help me in this regard.
11 Oct 2013 by ASP.NET Community
Concept A very common question asked on the ASP.NET Forums is how to bind a ListControl's DataTextField or DataValueField to multiple Columns. The
23 May 2014 by Sebastiaan Meijerink
Breeze pitfall. Understanding entityQuery function changing.
10 Aug 2010 by Laurence Moroney-MSFT
How to use WebMatrix to build a blog site in 15 minutes or less
22 Nov 2015 by MaikelO1
I would like to apply the following exception to my script..ListBoxKlanten.Items.Count == 0The idea is that when the listbox "ListBoxKlanten.Items.Count == 0" that the "listBoxKlantenContact" is made blank. (it is possible that there ready records in "listBoxKlantenContact") How do I...
23 Nov 2015 by MaikelO1
Problem solved, Thank you for your help!!if (ListBoxKlanten.Items.Count == 0) { command.Parameters.AddWithValue("@SELKlantcontactinfoID", DBNull.Value); } else { ...
19 Nov 2013 by iratus7
Hello there...I want to show in one gridview one item from one sqldatasource(first), one item from a second datasource and one other item from another (third)datasource. Any idea how it can be shown three sqldatasources in one gridview?This is just an example:
19 Nov 2013 by bowlturner
If they have a 1 = 1 = 1 relationship, then combine the queries (datasources) to give you one result set back. If these are 3 disparate data sets, then you'll need three different gridviews, but you can put them all in one table. A datagrid is similar to a database table, each row...
17 Oct 2014 by sashkhdr
Can we delete clusterd index on primary key....can we add non clustered index on primary key
17 Oct 2014 by Wendelius
You can for example drop the clustered primary key and then create the primary key with NONCLUSTERED definition. For example:ALTER TABLE MyTable ADD CONSTRAINT PK_MyTable PRIMARY KEY NONCLUSTERED (MyKey);See: ALTER TABLE[^] and table_constraint[^]
17 Oct 2014 by Shweta N Mishra
Yes, You can do but you primary key constraint will also be deleted.And yes you can have the non clustered index on primary key.You can use belowalter table dbo.Table drop constraint pk_idalter table dbo.Table add constraint pk_id primary key nonclustered (id)
25 Jun 2015 by Abhishek Burrnwal
Change status automatically using trigger from database when system date and date(from database) are equalMy table is-:EmployeeId Status Date1 false 2015-06-25 2 false 2015-06-25 3 false 2015-06-26 4 false 2015-06-26If system date...
25 Jun 2015 by John C Rayan
For MySQL , follow thishttps://dev.mysql.com/doc/refman/5.1/en/events-overview.html[^]
27 Feb 2024 by Member 11776570
If i have created cluster index it should work faster than other. But when i check execution plan it show me 100% cost for it. Below is the example Table1 Col1 Col2 Col3 CREATE CLUSTERED INDEX LK_table1 ON Table1 (Col1, Col2, Col3) But i have...
27 Feb 2024 by Richard Deeming
Firstly, the "100% cost" just means that your clustered index scan/seek accounts for 100% of the cost of that query. It doesn't mean that the query is less efficient than it would be without that index. Secondly, you need to design your indexes...
3 Dec 2015 by Member 12138525
@GroupId int, @StartDate DATETIME = NULL, @EndDate DATETIME = NULL, @RegionCode varchar(30) = NULLASBEGIN DECLARE @AgencyTable TABLE (GpoId int, OfcId int, Total_Bills BIGINT, Bill_Value BIGINT, Commission BIGINT, Total_Amount BIGINT) SET @EndDate = convert(datetime,...
3 Dec 2015 by Member 12138525
I have done it there is a problem of DataSet
14 Feb 2014 by ravikhoda
HI,i want to compare a value for two columns in the database.like i have a value called vehicleid. before insert into dataabse i want to compare that with two columns vehicleidin / vehicleidout. if that value is not present with any of the row for these two columns than and only it will...
14 Feb 2014 by Appdev(Icode)
HiTry it out....Insert into orders (orders_id, customers_id, customers_cid, customers_vat_id, customers_name, customers_email_address)select o.*from Test.dbo.orders owhere not exists ( select 1 from CobraDemoData.dbo.Data a ...
26 Jul 2016 by Viraj Suthar
I Want to import and export Complex excel in Datagridview and as per that excel some calculation happening like already existing quantity and if i import new excel than that quantity make addition as per their product and its price as well as total that also perform it self. How can i does this...
26 Jul 2016 by Richard MacCutchan
See Working with MS Excel(xls / xlsx) Using MDAC and Oledb[^].
8 Mar 2012 by Ramanujam Shankar
Using COALESCE function - concatenate many rows into a single text string output in SQL Server.
25 Feb 2012 by e-Lopes
How to concatenate many rows into a single text string using SQL Server 2008.
25 Feb 2012 by Sanjay K. Gupta
How to concatenate many rows into a single text string using SQL Server 2008
1 Dec 2014 by GDdixit
i am currently using "sql server 2012" .i have tried an effort of Concatenat two char type of variable ... DECLARE @FirstName Char(20) = 'ruchrmitl', @LastName Char(20) = 'kolkata' if we find how much space it has been taken in db ... than ..SELECT DATALENGTH(@FirstName)...
1 Dec 2014 by DamithSL
DATALENGTH Returns the number of bytes used to represent any expression. so in your first sql statement 20 means 20 bytes in your Char(20) fields.but len(@FirstName + ' ' + @LastName) give you number of characters of the specified string expression, excluding trailing blanks.So your...
1 Dec 2014 by /\jmot
DATALENGTH :Returns the number of bytes used to represent any expression.LEN :Returns the number of characters of the specified string expression, excluding trailing blanks.see this, you'll get the...
1 Dec 2014 by syed shanu
Its beacuse you have delared as Char.In SQL Char data type is fixed length data type.iots better you can use Varchar datatype See your query below :DECLARE @FirstName Char(20) = 'ruchrmitl',@LastName Char(20) = 'kolkata' DECLARE @FirstName1 varchar(20) = 'ruchrmitl',@LastName1...
1 Dec 2014 by Maciej Los
There is a bit difference between char and varchar[^] data types:char [ ( n ) ] Fixed-length, non-Unicode character data with a length of n bytes. n must be a value from 1 through 8,000. The storage size is n bytes. The SQL-2003 synonym for char is character.varchar [ ( n | max ) ] ...
19 Apr 2017 by Oggies14
How can I link two sql databases on a different environment. The one I have to login through vpn (Pulse) and the other one is on my network. I need this to update columns in the database that I connect to through vpn. Please help What I have tried: Have tried the following: select * from...
19 Apr 2017 by CHill60
As @RyanDev said, set up the database on the VPN as a Linked Server. There is an article on older versions here on CodeProject How to Config Linked Servers in a Minute[^] and another example here - Setting up a Linked Server for a Remote SQL Server Instance — DatabaseJournal.com[^] You've...
30 Sep 2014 by N. Altamura
Hi everyone, As wrote in the title I got a problem accessing to a database instance on a mobile application. Here the scenario: The application was developed on rugged PDA, Motorola MC9090, and work as a charm. I used visual studio 2008 for developing application with compact...
24 Apr 2019 by Member 13864666
Hi, So my problem over here is that, i have done back up on my sql database named 'SDP' then i have restored the sql backup file in another new PC. Now i would like to execute my vb.net program from the new PC. The problem i am facing is that the server name i have written in my codes are the...
22 Apr 2019 by phil.o
You can try 'localhost' as generic server name on local machine. Make sure SQL services listen to address 127.0.0.1
24 Apr 2019 by Richard Deeming
This is why you should always store your connection strings in your config file[^], as 0x01AA suggested in the comments. :) You might be able to get away with setting up an alias[^] for the old server. But you would need to set that up on every computer where you application needs to run.
30 Apr 2019 by itsathere
I want to create my whole database backup just on single button click and inside solution folder.After button click .bak file will be downloaded.Note:-I need C# code to backup database on button click event and inside solution folder or in any folder whatever i need as per...
30 Jul 2015 by Wendelius
One simple way is, using a SqlCommand, you execute a BACKUP[^] command. After the backup is successfully created, copy the files created where you want.Just make sure that - you have sufficient privileges.- the target folder is accessible by the credentials your program uses.
30 Jul 2015 by User 4180254
Below links will give you some idea about your question.http://stackoverflow.com/questions/9835553/how-to-backup-sql-database-programmatically-in-c-sharp[^]https://social.msdn.microsoft.com/forums/sqlserver/en-US/7690214d-4cba-4757-9956-05f0ca408db5/database-backup-programmatically[^]
18 Sep 2015 by Chris Quinn
SQL server can only backup to a drive that is accessible to the server - if you issue a command to backup a database to a folder on the C: drive, it will try to back it up to the C: drive on the database server, NOT to the C: drive on the machine on which the application is running (unless you...
6 Jan 2021 by Sherif Clemnt
can anybody solve a issue that occurs every time when i loading crystal report, it is asking for logon information What I have tried: private void button1_Click(object sender, EventArgs e) { if (TxtCustomer.Text == "" && TxtSONofrom.Text == "" && TxtSONoto.Text ==...
6 Jan 2021 by thatraja
You need to pass logon info dynamically in your code to avoid this issue. Agree with others, take a look at SQL Injection. C# Crystal Reports Dynamic Logon parameters[^]
15 Feb 2015 by Member 11262250
this error occurred when i change the database name in sql server but the the method running and im sure i changed the database name also in the connectionString how to solve this problem ... Plz------------------------------------------------------ protected void...
15 Feb 2015 by Gishaajeesh
Please ensure the select "Select * from SU_Seeker_Qualificationsstate .... " contains the column name "Type"
7 Oct 2020 by KriShna RaJendra N PraSad
Team, *I have a holiday list in Sql Table. *I have 2 services 1 and 2. *For service 1 need to add 30 days for the created date. *For service 2 need to add 5 days for the created date. Now I need to skip the holiday dates if the dates comes in...
8 Oct 2020 by Tan Chee Yong
Assuming your table name is TBL_Holidays and saturday, sunday are non-working days You can try this to get the working date: DECLARE @NoOfWorkingDays INT; SET @NoOfWorkingDays = 5; DECLARE @StartDate DATE SET @StartDate = '20201001' DECLARE...
19 Oct 2020 by OriginalGriff
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us...
11 Apr 2013 by Member 9978591
Hi,I would like to know how to use the Delete Command to delete records from a table in a database through GridView.This is what I did so far, with no avail.
11 Apr 2013 by Ashwin_Nikam
The problem seems the way you check the row that was selected for deletion.Also I cannot see the Content_ID as a bound field to be passed or retrieved in code behind.Should be defined before Content_Name. If e.CommandName.Equals("Delete") Then Dim rowID As...
11 Apr 2013 by Gopal Rakhal
write your code to delete in rowdeleting event of gridview
4 Jul 2012 by mathidioticz
I having this problem, and I seriously cannot figure out what is wrong with the code.. I had researched for weeks yet the same problem keep persist. I have a webform called UserProfile.aspx. After user logged-in, they can view and edit their particulars at UserProfile. I used a SqlDataSource...
24 Oct 2014 by ATjong
Different items in RadCombobox in each row of RadGrid with sqlDataSource
11 Nov 2011 by ffowler
Good day to you all.I am hoping someone could give a suggestion to a problem I am having on a ASP.NET page.I have 2 SQLDataSource object on the page and both have their parameters set via the Wizard; however, I would like to run only one or the other dependent upon a value in a Session...
11 Nov 2011 by Not Active
There is no trick to it. You are in complete control of your code. You just need to step away from the Wizard and learn to do it yourself.if(Session["Foo"] == "some value"){ myControl.DataSource = myDataSource1;}else{ myControl.DataSource = myDataSource2;}
11 Nov 2011 by ffowler
Harsh but true Mark. Thank you very much for your time. I realized that for this particular installation I have to let the Wizard go. Again, thanks for getting into my head.F
22 Sep 2010 by butterfly123
Hello Please try to solve my query :1) in form load i populated customer data in datagridview2) after some filtering i am displaying that data in another DGV3) i created a button 4) Now i wanted when i click the button 2 DGV data should save in database tablei tried...
2 May 2017 by Member 12605293
Hi While Using the alias names of each row I am getting multiple Duplicate Grids on scrolling Down the grid What I have tried: SELECT T.DeptID As DeptID ,SUM(CASE WHEN datepart(yyyy,T.DOJ) between 2005 and 2017 and T.Status =0 then 1 else 0 END) As TotalHeadCount, SUM(CASE when...
2 May 2017 by Wessel Beulink
You need to give every row it's own id or class. Simple fix is to put your table inside a container. Also best way is to set the container with a height and width as fixed height. //add table here
25 Mar 2014 by Mohamed Ghandour
I am trying to View a report dynamically from code behind. But when the parameters are changed from dynamic textboxes added in the page. in the report refresh() the data is not changed.I call sqlDS() and reportBuild() in the !IsPostback.This method is for defining the...
25 Mar 2014 by vsrikanth87
try thisreportViewer1.LocalReport.DataSources.Clear();reportViewer1.LocalReport.DataSources.Add(datasource);this.reportViewer1.RefreshReport();
30 Mar 2014 by Mohamed Ghandour
Thanks I got a better and easier way to solve this problem using this linkhttp://www.igregor.net/post/2007/12/Adding-Controls-to-an-ASPNET-form-Dynamically.aspxAnd you can use array of strings to pass attributes.
19 Apr 2014 by AldoBlack
Hello,http://i.stack.imgur...
20 Apr 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Try below code inside the SelectedIndexChanging Event.GridViewRow row = GridView1.Rows[e.NewSelectedIndex];DropDownList ddl = row.FindControl("ddlDropDownList") as DropDownList;someLabel.Text = ddl.SelectedValue.ToString();OP 's replyNope. It doesn't work, but I figured out the...
20 Apr 2014 by Abhinav S
Tryhttp://www.aspsnippets.com/Articles/How-to-get-Selected-Row-cell-value-from-GridView-in-ASPNet.aspx[^]http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedrow%28v=vs.110%29.aspx[^]http://www.aspsnippets.com/Articles/Selecting-GridView-Row-by-clicking-anywher...
22 Aug 2017 by ambilykk
How to enable SQL Express user
31 Jan 2012 by cutexxbaby
i have this gridview, and i use sqldatasource this is my select command SELECT Date.dateAvailable FROM LessonDate INNER JOIN Date ON LessonDate.dateID = Date.dateID WHERE (LessonDate.lessonID = @lessonID)however when i want to update the dateAvailable column UPDATE ...
31 Jan 2012 by Abhinav S
@LessonDateID is probably of varchar type.Try using CAST or CONVERT and convert[^] this varchar to DateTime.
28 Jun 2018 by Member 13864666
Hi, i am doing a sql question, n i typed out a code, it shows an error which is related to the Where Clause and subqueries. Pls someone give me a solution. What I have tried: SELECT B.movie_title AS 'Movie Title', A.branchID AS 'Branch ID', C.dvdID AS 'Total_Number_of_DVD' FROM RENT A JOIN...
28 Jun 2018 by #realJSOP
Try it something this: SELECT B.movie_title AS [Movie Title], A.branchID AS [Branch ID], C.dvdID AS [Total_Number_of_DVD] FROM RENT AS A INNER JOIN MOVIE AS B ON B.movieID = A.movieID INNER JOIN DVD AS C ON C.dvdID = A.dvdID WHERE A.dvdID IN (SELECT A.dvdID from...
28 Jun 2018 by amit kalshetti
use only one where clause and for another condition use and / or clause not where... Only One where clause we can use otherwise give syntax error.
26 Aug 2012 by smsheethal
Hiwhile connection to the server i found the error , it will not accept special characters. i tried using % before and after the special character then also it showing errors.string sqlConn = "Data Source=USER-PC%'"+\+"' %CompanyName';Initial Catalog=rack;User...
26 Aug 2012 by Kuthuparakkal
try this:string sqlConn = "Data Source=USER-PC\\CompanyName;Initial Catalog=rack;User ID=trial;Password=trial112";If it's local PC, use dot as :"Data Source=.;Ini.....If you are struggling with name try to ping User-PC\CompanyName...The syntax of connection...
26 Aug 2012 by Aarti Meswania
string sqlConn = "Data Source=USER-PC\CompanyName;Initial Catalog=rack;User ID=trial;Password=trial112";see data-source value it should be same as you find in login window while open your sql server e.g.'server name' = xyz\SQLEXPRESSthenconnection string should like below string...
26 Aug 2012 by Dev-0001
string sqlConn =@"Data Source=USER-PC;Initial Catalog=rack;User ID=trial;Password=trial112";http://www.connectionstrings.com/[^]
21 Mar 2015 by terzasek
Hello everyone.I need to build stand alone (WinApp+Database) for install on another PC.When work on my PC i'm import database file (.dbf) to my Windows Application project, it's work fine.But when install this project on another PC it does'n work and get this error (see the link...
21 Mar 2015 by OriginalGriff
"The server was not found or was not accessible"What do you think that means?Look at your data source: (LocalDB)\\v11.0That's fine for a development machine, but in production it is very, very unlikely to be right. You need to have a connections string that is stored in a parameter file...