sqldatareader

SqlDataReader problem

My problem is that this does not work; while (reader.Read()) { if (reader.NextResult() == true) { json.AppendFormat("{{\"AvgDate\": \"{0}\"}},{{\"MarkerID\": \"{1}\"}},", reader["AvgDate"], reader["MarkerID"]); } But this works; while (reader.Read()) { json.AppendFormat("{{\"AvgDate\": \"{0}\"}},{{\"MarkerID\": \"{...

Search database returning results to gridview via sqldatareader

I am trying to create a search page, this allows the admin to search through the entries in the database by certain criteria, such as province (like state but diff country) Here is the code I have so far. The problem is that I am not getting any errors. But I am also not getting any results. The page just posts back and returns to the b...

SqlDataReader inside SqlDataReader

how can i implement an SqlDataReader inside another SqlDataReader? my problem is i have an SqlDataReader. i am issuing while(reader.read()) and inside the while loop i have to create another SqlDataReader to read from the database. but i'm getting exceptions about connection being already open. so whats the best way to solve my problem ...

adding a dataset inside a datareader in vb.net

i hope i have asked the question title correctly. let me explain my issue - i am making a table through vb.net code (htmltablecell, htmltablerow..) no this table populates with an sql query and works perfectly. but inside this table in one tablecell, i need to add a dropdownlist which shall require a completely differernt query and shall...

SqlDataReader.GetSchemaTable() return ColumnName into Upper Case?

Hi all, I'm using SqlDataReader.GetSchemaTable method and I realized that return ColumName into Upper Case mode. There is any way to avoid this? The code I'm using is: System.Data.DataTable dt = reader.GetSchemaTable(); and I found into dt.Rows[i]["ColumnName"].ToString() the name of Column into Upper Case; for example if I hav...

dataset using where condition from another query

here's my code. I have a dataset that has its values and then i run an independent query which uses the same tables as dataset. now when i run the dataset, i want it to get a where condition on the query result. here's the code - sql = "SELECT ID, name FROM books WITH(NOLOCK) WHERE id =" & Session("ID") ds = FillDataset(sql) ...

SqlDataReader / DbDataReader implementation question

Does anyone know how DbDataReaders actually work. We can use SqlDataReader as an example. When you do the following cmd.CommandText = "SELECT * FROM Customers"; var rdr = cmd.ExecuteReader(); while(rdr.Read()) { //Do something } Does the data reader have all of the rows in memory, or does it just grab one, and then when Read is c...

C#: Is this the correct way to use the SqlDataReader for DAAB

Hello, I have just started using the Data Access Application Block from microsoft. There are very few instructions on the correct way to use the library. Just wanted to know if this is the correct way to use the data reader. SqlDataReader reader = SqlHelper.ExecuteReader(config.ConnectionString, CommandType.Text, "select * from category...

VB.net Debug sqldatareader - immediate window

Scenario is this; I've a sqldatareader query that seems to be returning nothing when I try to convert the sqldatareader to a datatable using datatable.load. So I debug into it, I grab the verbose SQL query before it goes into the sqldatareader, just to make sure it's formatted correctly. I copy and paste this into SQL server to run it a...

IndexOutOfRangeException when a stream is a multiple of the buffer size

I don't have a lot of experience with streams and buffers, but I'm having to do it for a project, and I'm stuck on an exception being thrown when the stream I'm reading is a multiple of the buffer size I've chosen. Let me show you: My code starts by reading bufferSize (100, let's say) bytes from the stream: numberOfBytesRead = DataRea...

If we cannot retrieve output parameters until SqlDataReader is closed, then why...?

1) While the SqlDataReader is being used, the associated SqlConnection is busy serving the SqlDataReader, and no other operations can be performed on the SqlConnection other than closing it. This is the case until the Close method of the SqlDataReader is called. For example, you cannot retrieve output parameters until after you call ...

What is wrong with this null check for data reader

c.Open() r = x.ExecuteReader If Not r("filename").IsDbnull Then imagepath = "<img src='images/'" & getimage(r("filename")) & " border='0' align='absmiddle'" End If c.Close() r.Close() I have also tried; If r("filename") Is DBNull.Value Then ...

Repeater not repeating :0) (asp.net)(vb)

Morning stackoverflow, I have a repeater, with the following code in my aspx page; <asp:Repeater ID="Contactinforepeater" runat="server"> <HeaderTemplate> <h1>Contact Information</h1> </HeaderTemplate> <ItemTemplate> <table width="50%"> <tr> <td colspan="2"><%#Container.DataItem("position")%></td> </tr> <tr> <td>Name:</td> <td><%#Cont...

Is closing/disposing an SqlDataReader needed if you are already closing the SqlConnection?

I noticed This question, but my question is a bit more specific. Is there any advantage to using using (SqlConnection conn = new SqlConnection(conStr)) { using (SqlCommand command = new SqlCommand()) { // dostuff } } instead of using (SqlConnection conn = new SqlConnection(conStr)) { SqlCommand command =...

SqlDataReader & user control

i try to use userControl to display SqlDataReader data. in the main page public SqlDataReader Data2; ... <uc1:WebUserControl ID="WebUserControl1" RData1="<%=Data2 %>" runat="server" /> and in the userControl Repeater1.DataSource = RData1; Repeater1.DataBind(); <asp:Repeater ID="Repeater1" runat="server"> ...

Is SQLDataReader slower than using the command line utility sqlcmd?

I was recently advocating to a colleague that we replace some C# code that uses the sqlcmd command line utility with a SqlDataReader. The old code uses: System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + sqlCmd); wher sqlCmd is something like "sqlcmd -S " + serverName + " -y 0 -h-...

Having problems with sqlDataReader

I am using a sqlDataReader to get data and set it to session variables. The problem is it doesn't want to work with expressions. I can reference any other column in the table, but not the expressions. The SQL does work. The code is below. Thanks in advance, Anthony Using myConnectionCheck As New SqlConnection(myConnectionString) ...

SqlDataAdaptor why get a different query

Hi All, I have a database reader class. But ı want to use this class, sometimes SqlDataAdaptor.Fill() method get another query to Datatable. I look at Query in SqlCommand Instance and my query is correct but returning values from different table? What is the problem? This My Code public static DataTable GetLatestRecords<T>(string Ta...

Should I implement IDisposable here?

My method which calls SQL Server returns a DataReader but because of what I need to do - which is return the DataReader to the calling method which resides in a page code-behind - I can't close the connection in the class of the method which calls SQL server. Due to this, I have no finally or using blocks. Is the correct way of disposi...

Cast error on SQLDataReader

My site is using enterprise library v 5.0. Mainly the DAAB. Some functions such as executescalar, executedataset are working as expected. The problems appear when I start to use Readers I have this function in my includes class: Public Function AssignedDepartmentDetail(ByVal Did As Integer) As SqlDataReader Dim reader As SqlDataRe...