sqldatareader

Deallocation of SqlDataReader

只愿长相守 提交于 2019-12-25 19:13:14
问题 I have a contractor that wrote code like this all over the place when we execute sql queries: sql.Append(string.Format("SELECT TableId FROM ps_SavedTables WHERE guid = '{0}'", guid)); using (IDataReader reader = SqlHelper.GetDataReader(sql.ToString())) { if (reader.Read()) { result = reader.IsDBNull(0) ? string.Empty : reader[0].ToString(); } //CDW added to close SqlDataReader reader.Close(); } The GetDataReader class was in an App_Code helper file and is declared like so: public static

Deallocation of SqlDataReader

Deadly 提交于 2019-12-25 19:13:02
问题 I have a contractor that wrote code like this all over the place when we execute sql queries: sql.Append(string.Format("SELECT TableId FROM ps_SavedTables WHERE guid = '{0}'", guid)); using (IDataReader reader = SqlHelper.GetDataReader(sql.ToString())) { if (reader.Read()) { result = reader.IsDBNull(0) ? string.Empty : reader[0].ToString(); } //CDW added to close SqlDataReader reader.Close(); } The GetDataReader class was in an App_Code helper file and is declared like so: public static

Deallocation of SqlDataReader

纵然是瞬间 提交于 2019-12-25 19:12:37
问题 I have a contractor that wrote code like this all over the place when we execute sql queries: sql.Append(string.Format("SELECT TableId FROM ps_SavedTables WHERE guid = '{0}'", guid)); using (IDataReader reader = SqlHelper.GetDataReader(sql.ToString())) { if (reader.Read()) { result = reader.IsDBNull(0) ? string.Empty : reader[0].ToString(); } //CDW added to close SqlDataReader reader.Close(); } The GetDataReader class was in an App_Code helper file and is declared like so: public static

SqlDataReader InvalidOperationException

好久不见. 提交于 2019-12-25 18:18:07
问题 I have a SqlDB.dll that has the function: public SqlDataReader getEnumValues(int enumId) { SqlDataReader reader = null; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand command = new SqlCommand( "SELECT * FROM [EnumValue] WHERE enumId LIKE '" + enumId + "';", connection); reader = command.ExecuteReader(); //if(reader.Read()) // Debug.WriteLine("Inside sqlDb->getEnumValues command = " + command.CommandText + " reader[name] = " + reader[

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

Populating Mysql Data to asp calendar takes too long to load

情到浓时终转凉″ 提交于 2019-12-25 03:30:15
问题 I'm creating a leave calendar for employees, And for that I'm populating some data onto the calendar using dataset , but it takes too long to load the data. I'm using multiple MySqlDataReader and connections to read the data from MySql table for each row of the calendar table. Maybe using multiple connections and readers might be the cause of slowing down but I'm not sure. The below is the code I use to populate the data. class Sample { public DateTime Date { get; set; } public string

how to get data to textbox from the database

我们两清 提交于 2019-12-25 02:20:17
问题 I have a form with one combo box and text box, and an SQL database named balance with two columns; one as customername and the other as obbalance . I had bound all of the customer name to the combo box, now what I have to do is, when a user selects a customer name from the combo box, the text box should show the obbalance of the selected customername ; here, the customer name will not be repeated - only one name per customer. What can I do? Please help me. Dim conectionstring As String

Column longtext exceeds the MaxLength limit

有些话、适合烂在心里 提交于 2019-12-24 16:44:20
问题 This error occur on modifying data in datable if dt has longtext column. First I load datatable: var command = new MySqlCommand(queryTableData, connection); DataTable table = new DataTable(); try { connection.Open(); table.Load(command.ExecuteReader()); } And when I am trying to modify any column data: table.BeginLoadData(); for (var i = 0; i < table.Rows.Count; i++) { table.Rows[i]["columnName"] = value; } table.EndLoadData(); It fails on table.EndLoadData(); with error: RowError: "Column

SqlDataReader.Read() always returning false

六眼飞鱼酱① 提交于 2019-12-24 16:36:55
问题 I have the following situation: using (SqlConnection conexao = new SqlConnection(ConnectionString)) { SqlCommand comando = new SqlCommand(query, conexao); comando.Parameters.AddWithValue("id", idUsuario); conexao.Open(); SqlDataReader reader = comando.ExecuteReader(CommandBehavior.SingleRow); if (reader.Read()) { Hydrate(out entity, reader); } } So, if reader contains valid results and HasRows == true , then reader.Read() should return true, right? Well, it doesn't for me. I have no idea of

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

一笑奈何 提交于 2019-12-24 10:48:37
问题 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"); List<string> a = new List<string>(); using (reader) { while (reader.Read()) { string t = reader.GetString(1); a.Add(t); } return a; } will everything get closed