datareader

while on IDataReader.Read doesn't work with yield return but foreach on reader does

天大地大妈咪最大 提交于 2019-12-06 12:07:01
问题 This is a commonly seen ADO.NET pattern to retrieve data from database using a data reader, but strangely doesn't work. Doesn't work: public static IEnumerable<IDataRecord> SelectDataRecord<T>(string query, string connString) where T : IDbConnection, new() { using (var conn = new T()) { using (var cmd = conn.CreateCommand()) { cmd.CommandText = query; cmd.Connection.ConnectionString = connString; cmd.Connection.Open(); using (var reader = (DbDataReader)cmd.ExecuteReader()) { // the main part

Linq to Sql vs Nhibernate vs SubSonic vs Stored Procedure (Help)

橙三吉。 提交于 2019-12-06 07:34:31
I am looking to develop a website for a news channel . So, Obviously its gonna receive a lot of hits daily and will be updated a lot on daily basis.. I have experience in ASP.Net and SQL Server.. These are the technologies i am considering to work with. Please help me choose the right method considering the amount of load it will take.. Technology?? 1) ASP.Net Webforms 2) ASP.Net MVC 1.0 And data access?? 1) Linq to SQL (Impressive but rumours say Microsoft is abandoning it) 2) Linq to Entities (Performance issues) 3) Datreader/Dataset 4) SubSonic (No idea) 5) NHibernate (No idea) Please

Storing results of a DataReader into an array in VB.NET

别说谁变了你拦得住时间么 提交于 2019-12-06 05:37:15
问题 How can I store the results of a DataReader into an array, but still be able to reference them by column name? I essentially want to be able to clone the DataReader's content so that I can close the reader and still have access. I don't want to store the items in a DataTable like everyone suggests. I've seen a lot of answers, but I couldn't really find any for what I wanted 回答1: The easiest way I've found to do this is by populating the array with dictionaries with Strings as keys and Objects

DataReader Behaviour With SQL Server Locking

久未见 提交于 2019-12-06 05:14:59
问题 We are having some issues with our data layer when large datasets are returned from a SQL server query via a DataReader . As we use the DataReader to populate business objects and serialize them back to the client, the fetch can take several minutes (we are showing progress to the user :-)), but we've found that there's some pretty hard-core locking going on on the affected tables which is causing other updates to be blocked. So I guess my slightly naive question is, at what point are the

Invalid attempt to read when no data is present in dr

主宰稳场 提交于 2019-12-06 01:36:39
I am trying to create a login form on my ASP.NET website. Currently, there's some problem. I am trying to incorporate the functionality such that the logged in user has the previlige to view only his profile. The code on the login page is this: business.clsprofiles obj = new business.clsprofiles(); Int32 a = obj.logincheck(TextBox3.Text, TextBox4.Text); if (a == -1) { Label1.Text = "Username/Password incorrect"; } else { Session["cod"]= a; Response.Redirect("profile.aspx"); } After logging in, the user is moved to the page where the person can view his profile once logged in. Session is

Intermittent System.IndexOutOfRangeException when reading a field from IDataReader

那年仲夏 提交于 2019-12-05 17:58:14
I have a very weird problem in code that I would not expect to ever fail. It is a website with some traffic but not that huge based on AspDotNetStoreFront. Site intermittently crashes when trying to read a database field from a reader. This happen on various places on the website. An example of such code is below on the line with object pValue = rs["PropertyValueString"]; private Dictionary<string, object> GetPropertValuePairs(string userName) { string query = string.Format("select PropertyName, PropertyValueString from dbo.profile with(nolock) where CustomerGUID = {0} and StoreID = {1}", DB

convert dataReader to Dictionary

耗尽温柔 提交于 2019-12-05 10:35:12
I tried to use LINQ to convert one row to Dictionary (fieldName -> fieldValue) return Enumerable.Range(0, reader.FieldCount) .ToDictionary<string, object>(reader.GetName, reader.GetValue); but I received error message: Instance argument: cannot convert from 'System.Collections.Generic.IEnumerable<int>' to 'System.Collections.Generic.IEnumerable<string>' How to correct this? return Enumerable.Range(0, reader.FieldCount) .ToDictionary( i => reader.GetName(i), i => reader.GetValue(i)); 来源: https://stackoverflow.com/questions/11842651/convert-datareader-to-dictionary

MySqlDataReader: DataTable.Fill(reader) throws ConstraintException

纵饮孤独 提交于 2019-12-05 08:26:59
I have two tables orders and orderdetails table orders (PK = id, UNIQUE index on orderno) |id|orderno| | 1|1000 | | 2|1001 | table orderdetails (PK = id) |id|orderid|item|qty| | 1| 1|ABC | 3| | 2| 1|XYZ | 4| Now I want to query the data with: SELECT o.orderno, od.item, od.qty FROM orders o INNER JOIN orderdetails od ON o.orderno = od.order which returns: |orderno|item|qty| |1000 |ABC | 3| |1000 |XYZ | 4| However If I use the following code to load the result into a DataTable it fails: var connectionString = "Server=localhost;Database=orders;Uid=root;"; var commandText = "SELECT o.orderno, od

Pause URL request Downloads

北城余情 提交于 2019-12-04 21:25:34
import urllib.request import re import csv import pandas as pd from bs4 import BeautifulSoup columns = [] data = [] f = open('companylist.csv') csv_f = csv.reader(f) for row in csv_f: stocklist = row print(stocklist) for s in stocklist: print('http://finance.yahoo.com/q?s='+s) optionsUrl = urllib.request.urlopen('http://finance.yahoo.com/q?s='+s).read() soup = BeautifulSoup(optionsUrl, "html.parser") stocksymbol = ['Symbol:', s] optionsTable = [stocksymbol]+[ [x.text for x in y.parent.contents] for y in soup.findAll('td', attrs={'class': 'yfnc_tabledata1','rtq_table': ''}) ] if not columns:

Regarding a small confusion about DataReader

三世轮回 提交于 2019-12-04 19:39:29
I was reading about DataReader and found a statement about DataReader which is not clear. here it is DataReader fetches the records from database and stores in the network buffer and gives whenever requests. It releases the records as query executes and do not wait for the entire query to execute. Hence very fast as compare to the DataSet which releases the data after loading all the data in memory. 1) it says that DataReader fetches the records from database and stores in the network buffer? i really do not understand what is network buffer? can anyone tell me what does it mean network buffer