Click here to Skip to main content
15,889,216 members
Everything / SqlDataReader

SqlDataReader

SqlDataReader

Great Reads

by Alexandros Pappas
This project provides utilities for SQL server, such as executing a list of SQL scripts, exporting data to an SQL script, and displaying relationships between records.
by Reeshabh Choudhary
Web platform based query builder to play with your database :)

Latest Articles

by Alexandros Pappas
This project provides utilities for SQL server, such as executing a list of SQL scripts, exporting data to an SQL script, and displaying relationships between records.
by Reeshabh Choudhary
Web platform based query builder to play with your database :)

All Articles

Sort by Score

SqlDataReader 

2 Dec 2014 by PIEBALDconsult
SqlParameter p = new SqlParameter("p1", name); -- should name be p1 ?In case I was unclear...SqlParameter p = new SqlParameter("p1", name p1);
25 Aug 2017 by Graeme_Grant
Those links are one side of the solution, the other is how to handle async calls in ASP.NET Webforms. I used this search: asp.net async webforms - Google Search[^] and found these two very helpful links for you: * Using Asynchronous Methods in ASP.NET 4.5 | Microsoft Docs[^] * The Magic of...
8 Dec 2018 by Wendelius
Taken that the id is created using an identity definition[^] there are three system functions that return lastly inserted identity value: - @@IDENTITY (Transact-SQL) | Microsoft Docs[^] - IDENT_CURRENT (Transact-SQL) | Microsoft Docs[^] - SCOPE_IDENTITY (Transact-SQL) | Microsoft Docs[^] ...
2 Dec 2014 by Syed Muhammad Ali Gardezi
Hello guys I am having a problem the read function of SQLDataReader is not returning anuthing. Please help me to figure out the problem. I am passing data from this function which by the way is of deleteEntry classstring name = this.textBox1.Text; string connstring = @"Data...
16 Aug 2016 by Maciej Los
I'd suggest to read this: Windows Search Data From Database and Filter in Datagridview sample in C# for Visual Studio 2012[^]Such of functionality is pretty easy to achieve:Get data from SqlDataReader into DataTable object (use Load method[^])Provide functionality to get single record...
7 Nov 2016 by Bigprey
This is my code for which I am getting the above said error when trying to delete the tournament. Since Tournament is associated with an image, the code calls the ImageDeletion function first and then the tournament count function before deleting the whole tournament.protected void...
7 Nov 2016 by Mehdi Gholam
Try closing your data reader in ImageDeletion():...while (reader.Read()) { string FilePath = reader[0] as string; string path = Server.MapPath(FilePath); FileInfo file = new FileInfo(path); if (file.Exists) { file.Delete(); } ...
19 Dec 2016 by Muhammd Aamir
Hi,EveryoneI am creating a web based project and I need to write data to textbox from database.i have made a function that return sqldatareader but how can i write this data that came from sqldatareader into text boxes. can anybody show me code for this...What I have tried:...
2 Aug 2017 by BasicProgrammer__
okay so I am using SQL Datareader and the code is below.. ltUP.Text = dr["UnitPrice"].ToString(); Now I wanted the "UnitPrice" to be shown in this format: {0:#,###.00}; because in my database its in float... I wanted for it to be in money when I display it in my aspx file.. What I have...
2 Aug 2017 by OriginalGriff
Try: tUP.Text = ((double)dr["UnitPrice"]).ToString("{0:#,###.00}");
25 Aug 2017 by DotNetFellow
hi I have been trying to get SqlDataReader to work using Async/Awaits but without much success. I got IEnumerable, cannot convert Task to SqlDataReader and some other errors. Here is basically my code and I must thank in advance to anybody who can really lend a hand to help out. //App_Code...
14 Nov 2018 by dom71_01
Hello, I've a little problem, I need your support.. This is the situation: I made a query using a sqlcommand ed a slqdatareader to read the result, foreach row resulting from this query, I need to make another query. I've write a while loop, if the datareader has rows, while datareader read, I...
14 Nov 2018 by Aydin Homay
Hi, In a more general way if you are looking for inserting a record into a SQL database you can find a nice and very well explain article in the below links: Simple ADO.NET Database Read, Insert, Update and Delete using C#.[^] Inserting values into a SQL Server database using ado.net via C# -...
14 Nov 2018 by Member 12893295
There are 2 way to do this 1)When you got the sqldatareader object then read that object if reader has data the you do another query on basis of reader object the again you got the reader object that time you need to create the Datarow object and insert the reader object values into datarow...
2 Dec 2018 by TheBigBearNow
I am creating a read/get method by Id this is my first time creating a method with 'using' statements so i am wondering how my method should be. where should i return the product and am i missing anything or any tips/ideas any input is appreciated. public static Product ReadProductById(int...
2 Dec 2018 by #realJSOP
I do it this way: SqlConnection conn = null; SqlCommand cmd = null; try { using (conn = new SqlConnection("blah blah")) { conn.Open(); using (cmd = new SqlCommand(...)) { //... your code } } } catch (Exception ex) { //... do something...
2 Dec 2018 by CHill60
You need to understand scope - have a read of this MSDN article Variable and Method Scope in Microsoft .NET[^] Looking at the code from your comment, you are declaring a second Product object for no good reason. product where it is declared is fine as it is available everywhere you want to...
10 Dec 2018 by TheBigBearNow
Hello everyone, I have a database table to store my receipt info and on my receipt I have a list of products on the receipt. To store a list I read I need to make another table of that list data and to link the receipt and list of my products together I’m supposed to link with receiptid. To...
8 Dec 2018 by TheBigBearNow
Hey all, I have my code to I can create a new receipt NEXT I am supposed to add my list of products to another table linked by my receiptId But my database automatically creates the receiptId and the only way to read the receipt from the database is if I have the receiptId So how would I get the...
10 Dec 2018 by RickZeeland
You can also use LINQ, this will take some study but provides a lot of power and flexibility. See example here: Simple LINQ to SQL in C#[^] And here: Querying SQL Server databases using LINQ to SQL[^]
5 Nov 2020 by Virendra S from Bangalore, Karnataka
I am trying to fetch a image from MS SQL DB. GetEmpImg() is getting called by in other class, i want return the bytes data. but return code is not reachable my code snippet: public static byte[] GetEmpImg(int emp_no) { ...
5 Nov 2020 by OriginalGriff
You can't return byte data there: it doesn't exist, because you haven't read it. You only read any data when there is at least one row available - and there should be only one row, so the while loop is redundant, just use an if instead - and...
22 Sep 2016 by Alexandros Pappas
This project provides utilities for SQL server, such as executing a list of SQL scripts, exporting data to an SQL script, and displaying relationships between records.
29 Nov 2015 by Reeshabh Choudhary
Web platform based query builder to play with your database :)
19 Dec 2016 by hari19113
As you didn't post DBConnection(), I'm assuming you are creating SQLConnection object inside it.I've created a working sample.SqlConnection con=null;Public SqlConnection DBConnection(){ string constring=; if (con==null) { con=new...
2 Aug 2017 by CPallini
I suppose you should retrieve the actual value, using the GetDouble[^] method (yes, a SQL FLOAT correspinds to a C# double) method and then format it according to your needs.
14 Nov 2018 by dom71_01
Thank you, but this isn't what I'm looking for; I know how to make a CRUD operations on SQL database. My problem is another. I make a query on a database table and with every record returned by it, I need to perform another query to different table and insert every result in a sqldatatable, and...
14 Nov 2018 by dom71_01
I've used the first solution, but what I haven't found is how can I insert a single record in a datatable. Here's an example of my code: ... first query.. if (datareader.HasRows()) { while(datareader.Read()) { query = ("SELECT field1, field2, field3 FROM table " + "WHERE...
2 Aug 2017 by GrpSMK
try like this below ltUP.Text = ((double)dr["UnitPrice"]).ToString("#,###.00");