- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在获取数据行值并将其转换为整数时遇到问题。该函数将通过数据表方法从数据库中检索数据并进行计数。我成功获得了计数值,我想使用该值来计算员工缺勤日。
Dim table As New DataTable
Dim AttendCommand As New MySqlCommand("SELECT COUNT(EmployeeID) AS AttendDay FROM employee.attendance WHERE EmployeeID=@EmployeeID AND month=@month", MysqlConn)
MysqlConn.Open()
AttendCommand.Parameters.AddWithValue("@EmployeeID", txtID.Text)
AttendCommand.Parameters.AddWithValue("@month", Cmonth)
Dim adapter = New MySqlDataAdapter(AttendCommand)
adapter.Fill(table)
If table.Rows.Count > 0 Then
test = CInt(table.Rows(0).ToString)
End If
MysqlConn.Close()
'count absence day after retrieve
Dim countTotal As Integer = 0
Dim total As Integer = 22
countTotal = total - test
我从调试中得到的结果是 countTotal=0。
最佳答案
@Plutonix 非常感谢您的建议,我设法获得了值(value)。
Dim test As Int32 = 0
Try
MysqlConn.Open()
test = Convert.ToInt32(AttendCommand.ExecuteScalar)
counTotal = total - test
Catch ex As Exception
End Try
我还确定了为什么我无法通过 dataTable 方法获取总值的问题。 (缺少.Item(0))
If table.Rows.Count > 0 Then
test = Convert.ToInt32(table.Rows(0).Item(0).ToString)
End If
两种方法都可以得到总值(value)
关于mysql - 如何将 system.data.dataRow 值转换为整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35817176/
我有一个扩展DataRow的类: import org.jdesktop.dataset.DataRow; public class MainDataRow extends DataRow { p
查看下面的代码块, DataTable _table = new DataTable(); //1) Why I need to Convert DataRow again into DataRow
我的代码: DataRow[] row = ByTotalTemplate.Select("TEMPLATE_ID=" + DisTemplateID); 一行包含TEMPLATE_ID、MIN_AM
使用这段代码: OracleDataTable dt = PlatypusSchedData.GetAvailablePlatypi(); OracleDataTable outputDt = new
假设我从多个线程访问一个DataTable。如果我想访问特定行,我怀疑我需要锁定该操作(我可能对此有误,但至少我知道这样我是安全的): // this is a strongly-typed tabl
我收到这个错误 "Error 8 Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Coll
我有很多如下形式的代码: // assume that MyDataRow is a datarow from a typed dataset and has a property called So
在我的表中,有数据行注释,它存储为文本数据类型。 我有 Datarow idPersonalstamm,它存储为 int。 我的问题是,有时来自 Personalstamm 的数据会被复制到评论中。
我正在尝试将文本框中的新词添加到表格中: private void addAnswer_Click(object sender, EventArgs e) { // Get a new row
我的模块中有一个 cmdlet,它从数据库表中返回一组通用 DataRows,其名称由 -Name 指定。范围 # this returns a collection of datarows from
我在此代码行中得到一个空引用: **DataRow dr = tableSelectedItems.NewRow();** 我不知道为什么。谁能帮帮我吗?我的代码应该填写用户在数据列表中选择的书籍。
我尝试将值从自定义集合传递给 DataRow 类型变量,如下面的代码: GridHitInfo downHitInfo = null; DataRow row = gridView3.GetDataR
我正在尝试比较循环中的两个 DataRow。但是,以下 if 语句不会返回 true: if (dt1.Rows[0]["Name"] == dt2.Rows[b]["Name"]) { //
我在一个网站工作。我无法转换表格中行[""] 中的数值。我的代码是: public partial class bought : System.Web.UI.Page { protected
每当我在 MySql 中运行此查询时,它总是返回 3 行具有相同 ID,但记录不同的行,但在我的代码中,它只返回 1 行。 这是我的代码: public DataTable DBSelect(stri
我有以下问题。我将值作为 XML(如字符串)进行传递,并且不会为数字列传递默认值,例如 false 或 0。因此,我创建了一个字典,其中键是列名,值是传递的值。 这是我当前的代码 foreach (K
我正在尝试将 DataTable 中的所有 DateTime 值转换为字符串。这是我使用的方法: private static void ConvertDateTimesToStrings(DataT
我明白了: DataTable dtEntity = CreateDataTable(); drEntity = dtEntity.NewRow(); 然后我将数据添加到该行(或不添加)。一大堆代
我遇到了 DataRow 的问题,这让我很头疼。 使用 OleDbConnection 从 Excel 电子表格中读取数据行。 如果我尝试使用列名从 DataRow 中选择数据,即使那里有数据,它也会
我正在尝试编写一个单元测试来比较两个数组。我已经定义了单元测试: [DataTestMethod] [DataRow( new[] { "COM3", "COM1", "COM2" },
我是一名优秀的程序员,十分优秀!