datareader

Passing DataReader from Method to .cs page - use CommandBehavior.CloseConnection but connection not closing

会有一股神秘感。 提交于 2019-12-12 05:48:38
问题 I use the following method in a class - which I call from .cs page filling a datareader: public static SqlDataReader getinfo(string username, string url) { //Initialise connection, string stored in Web.config SqlConnection conNs = new SqlConnection(ConfigurationManager.ConnectionStrings["conNs"].ConnectionString); SqlCommand cmdNs = new SqlCommand("usp_getinfo", conNs); cmdNs.CommandType = CommandType.StoredProcedure; cmdNs.Parameters.Add(new SqlParameter("@username", SqlDbType.VarChar, 50));

mysql datareader not finding rows c#

我与影子孤独终老i 提交于 2019-12-11 21:15:40
问题 I got a question about c# and mysql. I would like to make a very simpel login form that is connected to my local db. I got the connection to work (tested it) but i have a problem with reading my data that is returned from a select. I'm trying to put an ID into a string so I can display it(this is just for testing). Now I have searched a lot on google and almost everyone has something like this. When I execute it doesn't give error but my sqldatareader finds nothing. In the first if I ask if

How can I read from a DataRow or a DataReader using the same code?

谁说我不能喝 提交于 2019-12-11 09:52:46
问题 Currently, I am using a SqlDataReader loaded up with a simple database 'Select' query. Each row represents a domain object, so I inflate each object like this: Dim loadedItems As New List(Of Item) Dim dr As SqlDataReader = GetItemsDataReader() While dr.Read() Dim item As Item = GetItemFromData(dr) loadedItems.Add(item) End While The GetItemFromData method I wrote looks something like this: Private Function GetItemFromData(dr As SqlDataReader) As Item Dim loadedItem As New Item() loadedItem.ID

Creating a list with data from a Dataframe index in Python

元气小坏坏 提交于 2019-12-11 07:57:19
问题 i'm facing troubles trying to convert the index of df (see code) into a list, because when i run it this list is a "Timestamp" one (i dont know what that means). The code is quote='AAPL' stock = DataReader(quote,'yahoo',start_date,end_date) stock.head() df=DataFrame(stock) xdata = df.index.tolist() And then when run i get [Timestamp('2010-01-04 00:00:00'), Timestamp('2010-01-05 00:00:00'), Timestamp('2010-01-06 00:00:00'), Timestamp('2010-01-07 00:00:00'), Timestamp('2010-01-08 00:00:00')]

Retrieving large number of rows (more than 10 mil) in asp.net mvc application

丶灬走出姿态 提交于 2019-12-11 06:53:50
问题 I am working on asp.net mvc application and it provides the functionality of reading from ORACLE database using DATAREADER and present those rows to the user (sometimes up to 10 mil). The datareader read operation throws out of memory exception after reading about 900,000 rows. I was discussing this issue with my colleague and he suggested that I should use connectionless paradigm (may be Entity framework) or stored procedure and bring data in chunks. I wonder if there is someone out there

Reader.Read() fails to read rows even though it has rows

北城余情 提交于 2019-12-11 06:03:14
问题 I have a problem where it appears that the reader indicates that it has rows from the returned SQL but the while loop for the reader never runs. I put a messagebox in the reader.hasrows as a verification and I put a messagebox on the first line after the while loop as well. The messagebox for the hasrows is executed but the messagebox for the Read is not executed. It is very puzzling. I tried the query against the database and it indeed does return rows. Here is the code snippet. using

Why is that I get zeroes added to decimal values that I am pulling from MS Access database?

混江龙づ霸主 提交于 2019-12-11 05:15:55
问题 I originally asked this here, but had to ask separately. Why is it that I'm getting values like 2.01000000 from the database, even though I am storing only decimal 2.01? In my database I see it as 2.01 and not 2.010000. The field in MS Access is of type decimal, and I store it as 2.01 itself. I am pulling the value like this: while(reader.Read()) Convert.ToDecimal(reader[i]); I get the value as 2.010000000. Why? Is there a better approach to read decimal values from database? I have set the

Dynamically create JSON object for datareader results, regardless of what they look like?

老子叫甜甜 提交于 2019-12-11 05:09:47
问题 Right now I'm using Newtonsoft.json with my OdbcConnection and manually creating objects for each query I run. It looks something like this: Classes: public class payload { public string id; public string type; public DateTime timestmap; public object data; } public class resultPhrLastTime { public string facilityId; public string type; public string time; } Code: payload result = new payload(); var resultList = new List<resultPhrLastTime>(); result.id = "someid"; //connection stuff while

Datareader skips first result

余生颓废 提交于 2019-12-10 23:57:28
问题 I have a fairly complex SQL query that pulls different types of products from a database based on a customer ID. It pulls three different types of products, identified by their unique identifier number ranges (i.e., IDs 1000-1999 are one type of product, 2000-2999 are another, and 3000-3999 are yet another). SELECT b.fldMachineName, m2.fldRotaryPressName, mids.fldMachine_ID FROM dbo.tblCustomerGeneralInfo c LEFT JOIN dbo.tblMachine_IDs mids ON c.fldCustomer_ID = mids.fldCustomer_ID LEFT JOIN

Invalid attempt to Read when reader is closed

烈酒焚心 提交于 2019-12-10 17:24:21
问题 I have a common database class for my application and in that class i have a function public MySqlDataReader getRecord(string query) { MySqlDataReader reader; using (var connection = new MySqlConnection(connectionString)) { connection.Open(); using (var cmd = new MySqlCommand(query, connection)) { reader = cmd.ExecuteReader(); return reader; } } return null; } and on my code behind pages I use String sql = "SELECT * FROM `table`"; MySqlDataReader dr = objDB.getRecord(sql); if (dr.Read()) { //