mysqldatareader

c# - PropertyInfo set value List<object>

微笑、不失礼 提交于 2020-03-26 05:20:07
问题 PropertyInfo set value List<object> show error in convert list <object> I tried to convert to json and I couldn't public class PurchaseBill { public DateTime Date { get; set; } public string Type { get; set; } public string BillType { get; set; } public List<PurchaseProduct> Listproduct { get; set; } } public class PurchaseProduct { public Int64 id { get; set; } public String itemId { get; set; } public String image { get; set; } } code convert MySqlDataReader to list public static List<T>

How to check for NULL in MySqlDataReader by the column's name?

左心房为你撑大大i 提交于 2019-12-20 17:33:04
问题 How can I check for a NULL value in an open MySqlDataReader ? The following doesn't work; it's always hitting the else : if (rdr.GetString("timeOut") == null) { queryResult.Egresstime = "Logged in"; } else { queryResult.Egresstime = rdr.GetString("timeOut"); } rdr.IsDbNull(int i) only accepts a column number, not name. 回答1: var ordinal = rdr.GetOrdinal("timeOut"); if(rdr.IsDBNull(ordinal)) { queryResult.Egresstime = "Logged in"; } else { queryResult.Egresstime = rdr.GetString(ordinal); }//if

MySQLDataReader retrieving Null value problem in c#

牧云@^-^@ 提交于 2019-12-12 10:38:58
问题 I am currently working on a C# project that will export MySQL Data. The export is for any database within the server so I am not going to know what fields and the data types that are in the table and I am not going to know if a field in the table allows null values or not. During testing, I have found that the export is working fine but if the field allows null when the mysql data reader goes gets to the row which is null it displays an error SqlNullValueException, data is null. I have tried

Can I reset and loop again through MySqlDataReader?

故事扮演 提交于 2019-12-08 05:50:41
问题 I have a MySqlDataReader object, with the result of this query : SELECT warehouse, leasing, transportation, maintenance, manpower FROM retail WHERE zone = 'Central' GROUP BY warehouse And then I loop through the DataReader once, while (r2.Read()) { strXml.AppendFormat("<set label = '{0}'></set>",r2["warehouse"].ToString()); } And now I want to loop through it again...!! I know that DataReader is only a 'forward-only' object.. But is there any other solution for me here ? I'm asking, is there

MySqlDataReader: DataTable.Fill(reader) throws ConstraintException

霸气de小男生 提交于 2019-12-07 08:10:37
问题 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

Can I reset and loop again through MySqlDataReader?

喜你入骨 提交于 2019-12-06 16:50:06
I have a MySqlDataReader object, with the result of this query : SELECT warehouse, leasing, transportation, maintenance, manpower FROM retail WHERE zone = 'Central' GROUP BY warehouse And then I loop through the DataReader once, while (r2.Read()) { strXml.AppendFormat("<set label = '{0}'></set>",r2["warehouse"].ToString()); } And now I want to loop through it again...!! I know that DataReader is only a 'forward-only' object.. But is there any other solution for me here ? I'm asking, is there any any efficient way to hold data other than MySqlDataReader ? You can use below : using

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

MySqlDataReader GetBytes buffer issue…

╄→尐↘猪︶ㄣ 提交于 2019-12-04 04:47:56
问题 I've found a curious quirk of the MySqlDataReader.GetBytes implementation and just wondering if this is well known as I can't seem to find any articles about it on the net. If you follow the code example for the SqlDataReader and apply it to the MySqlDataReader it wont work...unless the number of bytes in the record you are retreiving is exactly divisible by the buffer. So for example if you are on the last iteration of the loop and there is only 100 bytes left but it's trying to read another

How to check for NULL in MySqlDataReader by the column's name?

老子叫甜甜 提交于 2019-12-03 04:58:27
How can I check for a NULL value in an open MySqlDataReader ? The following doesn't work; it's always hitting the else : if (rdr.GetString("timeOut") == null) { queryResult.Egresstime = "Logged in"; } else { queryResult.Egresstime = rdr.GetString("timeOut"); } rdr.IsDbNull(int i) only accepts a column number, not name. var ordinal = rdr.GetOrdinal("timeOut"); if(rdr.IsDBNull(ordinal)) { queryResult.Egresstime = "Logged in"; } else { queryResult.Egresstime = rdr.GetString(ordinal); }//if or if(Convert.IsDBNull(rdr["timeOut"])) { queryResult.Egresstime = "Logged in"; } else { queryResult

Using MySQLConnection in C# does not close properly

对着背影说爱祢 提交于 2019-11-27 15:01:37
Final solution: The connection was added to the connection pool. So I closed it, but it still remained physically open. With the ConnectionString Parameter "Pooling=false" or the static methods MySqlConnection.ClearPool(connection) and MySqlConnection.ClearAllPools the problem can be avoided. Note that the problem was, that the connection was still alive when I closed the application. Even though I closed it. So either I don't use connection pooling at all or I clear the specific pool before closing the connection and the problem is solved. I'll take my time figuring out what's the best