Provides a way of reading a forward-only stream of rows from a SQL Server database.

learn more… | top users | synonyms

1
vote
1answer
14 views

Can I add a Parametercollection to another Parametercollection?

The SqlParameterCollection has an Add(SqlParameter) method, and AddRange(SqlParameter[]) method. Each has several overloads. Specifically, SqlCommand.Parameters is read only, and if I have a ...
-1
votes
1answer
36 views

Binding sqldatareader to gridview c#

I am creating an application for a asp.net class that I am taking. One of the pages in the application needs to allow a user to search for a specific student via last name or user ID. When the ...
0
votes
2answers
30 views

How to make DataReader start reading again from the beginning at a condition?

How to make dr.Read(); start reading again from the beginning if a condition is satisfied? Something like: sqlDataReader dr = command.ExecuteReader(); for(int i=0; dr.Read() ; i++){ if(condition ){ ...
-1
votes
3answers
38 views

How to get how many element datareader has read? [duplicate]

How to get the length of a datareader, something like: sqlDataReader dr = command.ExecuteReader(); dr.Read(); int L= dr.Length;// this doesn't work. ?
0
votes
1answer
27 views

ASP.Net VB Check if datas exist in database

How do I check if data existing in the database or is NULL. I'm getting the following error Object cannot be cast from DBNull to other types . Do I need to add IsDBNULL to the code? SignedOn.Text = ...
1
vote
2answers
26 views

DataReader Name Based Lookups - What's actually happening under the hood that makes them so much slower than ordinal based lookups in loops?

It makes sense that a name-based lookup might be a little slower with multiple matching rules than one that is an integer index. However, I have a hard-time believing that this explains a 3% (or 5-7% ...
2
votes
2answers
49 views

If statement - comparing datareader value to datetime

I'm hoping you guys can help with a little issue I'm having. I'm getting some errors when trying to check whether a datareader value is less than a specified dateTime value and need some help. ...
0
votes
1answer
36 views

SqlDataReader isn't working, it skips the part where it checks the username

I am working on a project that has 1 client and 1 server. I created also a Class library in which I put the code and than ad this class library as Reference at the Server and at the Client. And so I ...
-2
votes
2answers
64 views

Dynamically change button back color c#

I want to change with a timer helps the color of buttons contains in a flowLayoutPanel1. With my query code the color change right, but when the condition of query turn to false, my button don't ...
0
votes
3answers
38 views

SelectCommand.Connection is not initialized

I'm trying to access my database, from this method in my DataBaseOptions class. I'm using this with ASP.NET for web development. Whenever I run this method, In another class, I get following error: ...
0
votes
2answers
53 views

How to best clean up a SQLDataReader when using linq

I have a method that returns a data reader. Normally I would wrap a using around the data reader so that it gets disposed nicely after I iterate through it. THe problem is that I've chosen to ...
2
votes
0answers
65 views

Select a set of rows and UPDATE or REMOVE some: SqlDataReader or SqlDataAdapter+DataSet

I am new to ADO.net I need to retrieve from DB a set of rows, then iterate one-be-one and send them, conditionally, to some objects which may UPDATE or DELETE received row from DB. From SqlDataReader ...
0
votes
1answer
43 views

ASP.NET Read individual values from a custom seperated row in database

I store values that i save through a form in a database column named 'Properties' like: value1#||#value2#||#value3#||#value4 The question is how to retrieve for example 'value2' from this string ...
1
vote
2answers
55 views

Using SqlDataAdapter to page a SqlDataReader source

This question seems to be common and I went through this answer already. Unfortunately, my page still isn't being paged. Here's what my code looks like in C#: SqlCommand command = new ...
0
votes
1answer
77 views

How can I set the variable type with an if/then statement in c#?

I have a function which performs an SQL query. Depending on a registry value, it will either hit SQL Server or SQL Server Compact Edition. If it is using SQL Server CE, the line setting the recordSet ...
1
vote
2answers
131 views

C# Login screen using sql database not working

I have a simple login screen which, upon user clicking login button, should run the sql query to search for rows where the username == username text box, and password == password text box. This ...
0
votes
1answer
48 views

NHibernate's equivalent of LINQ to SQL's and EF's Translate<T>()

I have a query that due to performance reasons I need to craft the actual command using raw ADO.NET (it involves table-valued parameters). With LINQ to SQL or EF, I could simply pass the DbDataReader ...
0
votes
2answers
33 views

SQLDataReader Invalid object name

I am trying to authenticate a user through a login form by reading user details from my database UsersDB. On attempting to read, I get an error: Invalid object name: UsersDB I got no errors when ...
0
votes
2answers
82 views

Sql Query error asp.net c#

I am using the below code to get results from my table and bind it to a gridview control . But I get the following error: "System.Data.SqlClient.SqlException: Incorrect syntax near 'x'" at ...
0
votes
0answers
22 views

SqlDataReader exception squelching

Is there a way to force SqlDataReader to throw exceptions? There seems to be a very problematic behavior with it where SqlDataReader will have an exception and cause the function it's in to end ...
0
votes
0answers
24 views

How to resolved. Timeout issue cause of multiple reader

I have problem with OleDbDataReader Timeout. FYI, I have multiple OleDbDataReader in one try/catch. After reading, it will insert into same database. Refer to my sample code here: Dim ReadTerima, ...
0
votes
0answers
22 views

Generalizing the SqlDataReader pattern

I have a lot of code of the form: Using cn As New SqlConnection(MyConnectionString) cn.Open() Using cmd As New SqlCommand(MySqlText, cn) Using dr As SqlDataReader = ...
3
votes
1answer
100 views

rename rows in datatable

I currently am working with a database for a 3rd party application that has no form checks for data in the columns I am working with. I am using SqlDataReader (because this does not need to modify the ...
0
votes
1answer
32 views

No data is read in SqlReader Invalid attempt to read when no data is present.

I know this problem has been posted millions of times before, but this might be different. I am using a sql table with columns id,year,month,pdffile in my webpage, I would like the user to view the ...
0
votes
1answer
40 views

How can I tell if my SqlCeDataReader contains any vals after calling SqlCeCommand.ExecuteReader()?

With the code below: SqlCeDataReader myReader = cmd.ExecuteReader(CommandBehavior.SingleRow); itemID = myReader.GetString(0); packSize = myReader.GetString(1); ...I get an exception, "No data ...
0
votes
0answers
16 views

sqldatareader reads null

I'm using an SQLDataReader to retrieve a row of data from a table. public SalesOrderItem getSalesOrderQuantity(Int32 so_no, Int32 so_item_no) { string commStr2 = "SELECT * FROM ...
1
vote
2answers
297 views

MVC4 Send Datatable to View

I need to pass a list of TestModel into my view. This list will then be used to populate a grid. However, I want the members of TestModel to be created dynamically from headers in a datatable loaded ...
0
votes
1answer
107 views

SqlDataReader Convert byte to integer vb.net

I am trying to retrieve the information from a database table using SqlDataReader. I have two columns one string and the other is bit. The string will be filled in a textbox. But the problem with the ...
0
votes
1answer
47 views

already an open DataReader associated with this Command when am chekcing with invalid data

Private Sub txt_sname_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txt_sname.GotFocus Dim fcs As String fcs = "select fname,dept from nstudent where stid = '" ...
0
votes
1answer
32 views

Issues with writing BLOB data in chunk (8k)

I'm trying to write BLOB data on to a word file. Here is my code Dim reportID As Integer reportID = table1.report_output_data_id Dim aSqlStr As String = "SELECT file_data FROM ...
1
vote
3answers
172 views

Access a specific row in DataReader

I have a datareader to display a list of gameweeks in a js carousel. I need to be able to add an if statement to change the div class of the current gameweek. This is my current code: if ...
0
votes
2answers
81 views

Datareader not displaying first row

I am looping through my database to display a list of leagues a player is associated with. If a player is not a member of any leagues then a message displays to tell them. Here is the code if ...
0
votes
2answers
58 views

Building my own SqlDataReader object

I need some help. I've been back and forth on which direction I should go and there are some options of which none I like or can use. I wrote a generic data dump tool that pulls data from a ...
0
votes
1answer
52 views

Unable to Make this log in Form in c# / SqlDataReader Issue

I am trying to make a windows Form Application with a login screen,Form3 Will open Form1 if the username and password are correct. the code is linked to a database the code is as follows: private ...
0
votes
1answer
78 views

ASP.Net VB SqlDataReader Format

I have a SqlDataReader that reads data from the database. How can I format the phone number to return as (123) 456-7890 instead of 1234567890 on my aspx page? My reader as follow: txtFaxPhone.Text = ...
0
votes
0answers
215 views

No data displayed in datagridview in WPF

I have a WPF form with a system.windows.form.datagridview in it. Using a SQL query I retrieve data from a database and us a SQLreader to read the data. This is stored in a dataview that is bound to ...
0
votes
1answer
51 views

Using a literal to display results from query

I'm trying to display multiple rows from a query into a literal in asp.net c#. Here is my code for doing so: protected void Page_Load(object sender, EventArgs e) { SqlConnection ...
0
votes
1answer
76 views

Alternative to Recordset Looping

Back in the day using ADO, we used GetRows() to pull back an array and loop through it, because it was faster than using rs.MoveNext to walk through records. I'm writing an application that pulls ...
5
votes
2answers
159 views

How to read dynamic properties from database

I will try to explain my scenario the best way I can. I have the following tables in my database: Products{ProductId, CategoryId ...} Categories{CategoryId ...} CategoryProperties{CategoryPropertyId, ...
0
votes
0answers
73 views

Sqldatareader throwing providerbase.fieldnamelookup.getordinal(string fieldname) out of index error

I have a form based application where after selecting a SKU from drop down box, many different text boxes on the forms get populated by reading data from SQL. In my Sql datareader I have a condition ...
1
vote
1answer
261 views

The data types text and varchar are incompatible in the equal to operator

I am trying to access all the records from database on a data grid view depending upon the type of user logging in through a form having 2 text-boxes for user_name and password respectively and on ...
1
vote
1answer
102 views

How to return a temp table from a stored procedure to be used in a C# datareader?

I have the following stored procedure (T-SQL) and I'd like to call it using command.ExecuteReader in C# code so that I can loop through any errors raised OR call it from SQL directly. However, I am ...
-1
votes
3answers
43 views

Issue with calling two methods in data access method

I have this method: public bool ActivateUser(string username, string key) { var user = this.GetUser(username, true); if (user != null) { ...
3
votes
3answers
85 views

how to read a sql column containing commas as one field with c#

I have a sql08 database table which I am reading with C#. One of the columns (College) contains data where some data has a comma: Miami, FL or Miami, OH, and some don't: USC. My output .csv shifts ...
0
votes
3answers
212 views

SqlDataReader and SqlCommand

I have the following code. using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString)) { connection.Open(); SqlCommand ...
2
votes
1answer
67 views

Out of range error on SqlDataReader

I'm using a SqlDataReader and get this exception when trying to read a column... System.IndexOutOfRangeException: record Here is the code... SqlCommand select = new SqlCommand("SELECT ...
0
votes
4answers
433 views

Returning Datatable using SqlDataReader VS SqlDataAdapter which one is Better for performance wise

i want to know which one is better for returning Datatable. Here for Sqldatareader i use DataTable.Load(dr) Using SqlDataReader public static DataTable populateUsingDataReader(string myQuery) { ...
2
votes
1answer
77 views

Why 'IsDBNull' returns false for field that is NULLable in the DB? [closed]

I read data from DB using 'IDataReader' and simple query SELECT * FROM mytable ORDER BY Id The problem is that call to reader.IsDBNull(i) return 'false' even for nullable fields... and call to ...
0
votes
2answers
73 views

Removing duplicates from an array populated by a reader

I have a database column that has several names separated by commas in each row. I'm trying to populate a data-table containing all the names but without duplicates. Currently the list populates but ...
-1
votes
3answers
81 views

Error: Invalid attempt to call Read when reader is closed after the while loop?

Hello i have a method which reads some data from the sql and saves them to arrays. to find out how many rows the sql result has i wrote this: DataTable dt = new DataTable(); ...

1 2 3 4 5 9