ado.net

SqlDataReader does not return all records

倾然丶 夕夏残阳落幕 提交于 2019-12-25 05:22:26
问题 I am experiencing a problem with ADO.NET SqlDataReader. When I run underlying stored procedure directly in SSMS - it returns 1.7 million of records. When I run a related VB.NET code that fills an ADO.NET DataTable - I also get 1.7 million of records. But when I run a loop to fill a Generic list like this While i_oDataReader.Read m_aFullIDList.Add(i_oDataReader.GetInt32(0)) End While It returns a lot less records and that number can vary. At the end of the loop if I check m_aFullIDList.Count

I can't get correct max(len(fieldname)) of CSV file using Linq, SQL or MaxLength

[亡魂溺海] 提交于 2019-12-25 05:13:48
问题 I am trying to import a csv file and I need to get the maximum field length so I know how large to make my varchar field in the new table. I have a small table with the longest text value of 315. Here is a logical description of what is happening: If Len(Field) > 255 And RowNumOf315Record > 25 Then FieldLen = 255 If Len(Field) > 255 And RowNumOf315Record <= 25 Then FieldLen = 315 If we nuke all records with the field length > 255 then the correct length is always returned. I tried Linq: Table

The SqlParameter is already contained by another SqlParameterCollection - command.Parameters.Clear() does not work

点点圈 提交于 2019-12-25 05:06:48
问题 I am getting desperate here. I cant figure out why does this exception occur. I searched and read about this problem and it seems everyone managed to solve it with command.Parameters.Clear(), but this does not work for me. Here is my code: public class ProductsDataAccess : Connection { public static SqlParameter[] createParams(Products prod) { SqlParameter idParam = new SqlParameter("@id", prod.prodID); idParam.SqlDbType = System.Data.SqlDbType.VarChar; idParam.Size = 45; idParam.IsNullable =

Isolated ADO.NET connection and transaction within a transactionscope

♀尐吖头ヾ 提交于 2019-12-25 04:44:18
问题 Background: I have an ASP.NET MVC application that wraps controller actions in a TransactionScope using an Action Filter. Further downstream (in my infrastructure layer); I'd like to open up a new ADO.NET connection (to the same db as my outer TransactionScope, if that is relevent) and have it participate in its own transaction - without being tied to the current TransactionScope started at the controller level; how do I go about doing this? 回答1: You pass in TransactionScopeOption.RequiresNew

ado.net dirty records in dataset

为君一笑 提交于 2019-12-25 04:36:17
问题 I'll try to explain. I want to track dirty records in my dataset row that is bound to controls on window (wpf). It works fine. Lets say i begin to edit some textbox that is bound to dataTable in that dataSet. After i add one character to textbox, dataset is marked dirty. But if I delete that character again ( restore original value ), dataset is still dirty. I want after i restore original value to dataSet become not dirty, because in reallity it isn't dirty any more. Is there any method i

ODBC has SetRowsetSize, what is the equivalent in ADO.net?

前提是你 提交于 2019-12-25 04:31:22
问题 I am looking for ways to deal with a high latency connection. ODBC has a SetRowsetSize that solves this problem, as described here and here. Is there an equivalent of this setting in ADO.net? This article seems to suggest there is an analog in the original ADO, but it is very old and points to articles that no longer exist. Generally speaking, how does one improve performance in ADO.net for high-latency connections? 回答1: If you are concerned about latency while using ADO.NET with SQL Server,

ODBC has SetRowsetSize, what is the equivalent in ADO.net?

…衆ロ難τιáo~ 提交于 2019-12-25 04:31:05
问题 I am looking for ways to deal with a high latency connection. ODBC has a SetRowsetSize that solves this problem, as described here and here. Is there an equivalent of this setting in ADO.net? This article seems to suggest there is an analog in the original ADO, but it is very old and points to articles that no longer exist. Generally speaking, how does one improve performance in ADO.net for high-latency connections? 回答1: If you are concerned about latency while using ADO.NET with SQL Server,

Connecting to SQL Server in ASP.NET

坚强是说给别人听的谎言 提交于 2019-12-25 03:36:30
问题 I am trying to connect to the SQL Server from Visual Web Developer using asp.net but I am facing some problems If anybody helps in this regard i will be greatful. public partial class _Default : Page { protected void Page_Load(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("Server=localhost;" + "Database=DB;User ID=aaaa;" + "Password=aaaa"); conn.Open(); SqlDataReader reader = conn.ExecuteReader(); while (reader.Read()) { employeesLabel.Text += reader["Name"] + "<br />";

datalist itemdatabound event having issues changing item bg color on condition

别说谁变了你拦得住时间么 提交于 2019-12-25 03:15:23
问题 Hey guys I'm trying to do something really simple.. I'm checking a data column in my datarow if it's > 0 I want the item back color in the datalist to be green if its < 0 remain transparent... if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DataRowView drv = (DataRowView)(e.Item.DataItem); int rating = int.Parse(drv.Row["rating"].ToString()); if (rating > 0) { e.Item.BackColor = System.Drawing.Color.Green; } } I've stepped through with debugger

Binding Picture box

天大地大妈咪最大 提交于 2019-12-25 02:47:14
问题 I want to know if we can bind a picturebox as this example : Binding b = new Binding("Image", dataset, "Timage.imagee"); pictureBox1.DataBindings.Add(b); 回答1: Try using the Format event of the Binding object: Binding b = new Binding("Image", dataset, "Timage.imagee", true); b.Format += picFormat; pictureBox1.DataBindings.Add(b); private void pic_Format(object sender, ConvertEventArgs e) { Bitmap bmp = null; byte[] img = (byte[])e.Value; using (MemoryStream ms = new MemoryStream()) { ms.Write